Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32463
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-10-29 21:20 -0700 |
| References | (2 earlier) <mailman.3061.1351558251.27098.python-list@python.org> <6101355b-ae00-4482-96ee-ed60f5cb465f@googlegroups.com> <85ea1841-6849-4970-b08b-5c7bbb7bba14@googlegroups.com> <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com> <mailman.3068.1351566714.27098.python-list@python.org> |
| Subject | Re: date and time comparison how to |
| From | noydb <jenn.duerr@gmail.com> |
| Message-ID | <mailman.3070.1351570848.27098.python-list@python.org> (permalink) |
On Monday, October 29, 2012 11:11:55 PM UTC-4, Dave Angel wrote:
> On 10/29/2012 10:13 PM, noydb wrote:
>
> > I guess I get there eventually!
>
> > This seems to work
>
> >
>
> > pdf_timeStamp = time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf)))
>
> > intermediateTime = time.strptime(pdf_timeStamp, "%m%d%y%H%M%S")
>
> > pdfFile_compareTime = time.mktime(intermediateTime)
>
> >
>
> > (and I'll do the same to the user entered date-n-time and then compare)
>
> >
>
> >
>
> > Lastly, so can anyone chime in and tell me if this is a good method or not? Is there a better way?
>
>
>
> Please read the rest of the thread in particular the message 3 hours ago
>
> from Gary Herron
>
>
>
> import datetime, os, stat
>
> mtime = os.lstat(filename)[stat.ST_MTIME] // the files
>
> modification time
>
> dt = datetime.datetime.fromtimestamp(mtime)
>
>
>
> Now you can compare two datetimes simply by
>
> if dt1 < dt2:
>
>
>
> Or you can subtract them, and examine the difference.
>
>
>
> What's the need for all that string conversion stuff?
>
>
>
>
>
>
>
> --
>
>
>
> DaveA
okay, I see.
But for the user supplied date... I'm not sure of the format just yet... testing 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 input into a format to compare with dt above?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 16:13 -0700
Re: date and time comparison how to Gary Herron <gherron@digipen.edu> - 2012-10-29 17:04 -0700
Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 00:50 +0000
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-29 23:11 -0400
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
Re: date and time comparison how to Chris Angelico <rosuav@gmail.com> - 2012-10-30 17:12 +1100
Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-30 05:35 -0400
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 03:30 +0000
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
RE: date and time comparison how to "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-31 21:04 +0000
Re: date and time comparison how to Adam Tauno Williams <awilliam@whitemice.org> - 2012-11-02 07:22 -0400
csiph-web