[Python-ideas] use gmtime(0) epoch in functions that use mktime()

Akira Li 4kir4.1i at gmail.com
Sun Sep 7 20:05:11 CEST 2014


random832 at fastmail.us writes:

> On Sat, Sep 6, 2014, at 13:06, Guido van Rossum wrote:
>> There used to be systems with a different notion of epoch. Are there still
>> such systems around? OSX has the UNIX epoch -- what's it gmtime(0) on
>> Windows?
>
> If you call the time.h functions from the CRT library, they use 1970
> (and always have). Windows has _other_ functions that use a different
> epoch (1600, if I remember correctly), but they're native win32
> functions not called directly by python.

python does call these functions, look at the code that uses FILETIME
type.

For example, os.utime() uses the hardcoded 1970 Epoch on Windows
and converts it to FILETIME (1601 epoch in 100s of nanoseconds) to call
SetFileTime().

In this case, using 1970 Epoch is justified. gmtime(0) is documented as
"midnight (00:00:00), January 1, 1970, coordinated universal time (UTC)"
on Windows.


--
Akira



More information about the Python-ideas mailing list