[issue31646] bug in time.mktime

Eryk Sun report at bugs.python.org
Fri Sep 29 23:50:34 EDT 2017


Eryk Sun <eryksun at gmail.com> added the comment:

mktime() is the inverse of localtime(). With the given format string, strptime() sets tm_isdst to -1, for which mktime will use the system's timezone information to determine whether or not it's daylight saving time. You need to verify that the time zones are the same. 

For me the results agree in Linux and Windows with the local timezone on both systems set to the UK.

9 March (GMT, standard time)

    Linux
    >>> time.mktime(time.struct_time((2014, 3, 9, 2, 0, 0, 6, 68, 0)))
    1394330400.0
    >>> time.mktime(time.struct_time((2014, 3, 9, 2, 0, 0, 6, 68, -1)))
    1394330400.0

    Windows
    >>> time.mktime(time.struct_time((2014, 3, 9, 2, 0, 0, 6, 68, 0)))
    1394330400.0
    >>> time.mktime(time.struct_time((2014, 3, 9, 2, 0, 0, 6, 68, -1)))
    1394330400.0

9 August (BST, daylight saving time)

    Linux
    >>> time.mktime(time.struct_time((2014, 8, 9, 2, 0, 0, 6, 68, 1)))
    1407546000.0
    >>> time.mktime(time.struct_time((2014, 8, 9, 2, 0, 0, 6, 68, -1)))
    1407546000.0

    Windows
    >>> time.mktime(time.struct_time((2014, 8, 9, 2, 0, 0, 6, 68, 1)))
    1407546000.0
    >>> time.mktime(time.struct_time((2014, 8, 9, 2, 0, 0, 6, 68, -1)))
    1407546000.0

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31646>
_______________________________________


More information about the Python-bugs-list mailing list