Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'see.': 0.07; 'chime': 0.09; 'mtime': 0.09; 'skip:t 60': 0.09; 'subtract': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'thread': 0.11; 'modification': 0.15; '10:13': 0.16; 'above?': 0.16; 'string': 0.17; 'wrote:': 0.17; 'input': 0.18; 'import': 0.21; 'os,': 0.22; 'monday,': 0.23; 'seems': 0.23; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'ago': 0.27; 'cc:addr:gmail.com': 0.27; 'guess': 0.27; 'cc:2**2': 0.27; 'possible,': 0.27; 'rest': 0.28; 'gary': 0.29; 'way?': 0.29; "i'm": 0.29; "skip:' 10": 0.30; '(and': 0.32; 'anyone': 0.33; 'received:google.com': 0.34; 'entered': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'cc:no real name:2**1': 0.36; 'compare': 0.36; 'method': 0.36; "i'll": 0.36; 'october': 0.37; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'sure': 0.38; 'skip:" 10': 0.40; 'hours': 0.66; 'difference.': 0.84; 'lastly,': 0.84; 'angel': 0.93; 'examine': 0.95 Newsgroups: comp.lang.python Date: Mon, 29 Oct 2012 21:20:44 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.224.158.131; posting-account=1oR0EAoAAAANUNTZzTcJtVHDa9M690er References: <50e576ea-2ebe-4340-954e-6c23b5885680@googlegroups.com> <508F1973.2030907@digipen.edu> <6101355b-ae00-4482-96ee-ed60f5cb465f@googlegroups.com> <85ea1841-6849-4970-b08b-5c7bbb7bba14@googlegroups.com> <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 71.224.158.131 MIME-Version: 1.0 Subject: Re: date and time comparison how to From: noydb To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org, d@davea.name, noydb X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351570848 news.xs4all.nl 6936 [2001:888:2000:d::a6]:39029 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32463 On Monday, October 29, 2012 11:11:55 PM UTC-4, Dave Angel wrote: > On 10/29/2012 10:13 PM, noydb wrote: >=20 > > I guess I get there eventually! =20 >=20 > > This seems to work >=20 > > >=20 > > pdf_timeStamp =3D time.strftime("%m%d%y%H%M%S",time.localtime(os.pa= th.getmtime(pdf))) >=20 > > intermediateTime =3D time.strptime(pdf_timeStamp, "%m%d%y%H%M%S") >=20 > > pdfFile_compareTime =3D time.mktime(intermediateTime) >=20 > > >=20 > > (and I'll do the same to the user entered date-n-time and then compare) >=20 > > >=20 > > >=20 > > Lastly, so can anyone chime in and tell me if this is a good method or = not? Is there a better way? >=20 >=20 >=20 > Please read the rest of the thread in particular the message 3 hours ago >=20 > from Gary Herron >=20 >=20 >=20 > import datetime, os, stat >=20 > mtime =3D os.lstat(filename)[stat.ST_MTIME] // the file= s >=20 > modification time >=20 > dt =3D datetime.datetime.fromtimestamp(mtime) >=20 >=20 >=20 > Now you can compare two datetimes simply by >=20 > if dt1 < dt2: >=20 >=20 >=20 > Or you can subtract them, and examine the difference. >=20 >=20 >=20 > What's the need for all that string conversion stuff? >=20 >=20 >=20 >=20 >=20 >=20 >=20 > --=20 >=20 >=20 >=20 > DaveA okay, I see. But for the user supplied date... I'm not sure of the format just yet... te= sting with a string for now (actual date-date might be possible, tbd later)= , so like '10292012213000' (oct 29, 2012 9:30pm). How would you get that i= nput into a format to compare with dt above?