[Python-Dev] Adding the 'path' module (was Re: Some RFE forreview)
Anders J. Munch
ajm at flonidan.dk
Tue Jun 28 17:01:51 CEST 2005
> From: Guido van Rossum [mailto:gvanrossum at gmail.com]
>
> >>> datetime.datetime.utcfromtimestamp(time.time()) - datetime.datetime.utcnow()
> datetime.timedelta(0)
I overlooked the utcfromtimestamp method, sorry.
> Your bug is similar to comparing centimeters to inches, or speed to
> acceleration, or any number of similar mistakes.
Quite so, and that is exactly the point. time.time() unambiguously
identifies a point in time. A datetime object does not. At least not
unless a tzinfo object is included, and even then there is a corner
case at the end of DST that cannot possibly be handled.
If ctime/mtime/atime were to return datetime objects, that would
pretty much have to be UTC to not lose information in the DST
transition. I doubt that's what Walter wanted though, as that would
leave users with the job of converting from UTC datetime to local
datetime; - unless perhaps I've overlooked a convenient UTC->local
conversion method?
- Anders
More information about the Python-Dev
mailing list