[Python-Dev] PEP: New timestamp formats

Jeffrey Yasskin jyasskin at gmail.com
Fri Feb 3 19:48:13 CET 2012


On Fri, Feb 3, 2012 at 3:57 AM, Victor Stinner
<victor.stinner at haypocalc.com> wrote:
>> datetime.datetime
>>
>> - as noted earlier in the thread, total_seconds() actually gives you a
>> decent timestamp value and always returning UTC avoids timezone issues
>
> os.stat() and time.time() use the local time.

The documentation disagrees with you.
http://docs.python.org/dev/library/time.html#time.time says "Return
the time as a floating point number expressed in seconds since the
epoch, in UTC."

os.stat is documented less clearly, but it's implemented by forwarding
to the system stat(), and that's defined at
http://www.opengroup.org/sud/sud1/xsh/sysstat.h.htm#sysstat.h-file-desc-stru
to return times since the Epoch.
http://pubs.opengroup.org/onlinepubs/000095399/functions/localtime.html
says "January 1, 1970 0:00 UTC (the Epoch)"

> I don't see datetime without tzinfo as an issue.
>
> Being unable to convert a datetime to an epoch timestamp is also not
> an issue: if you need an epoch timestamp, just use float or Decimal
> types.

Your PEP still says, 'there is no easy way to convert it into "seconds
since the epoch"'. If you don't actually think it's an issue (which
it's not, because there is an easy way to convert it), then take that
out of the PEP.

Jeffrey


More information about the Python-Dev mailing list