[issue11850] mktime - OverflowError: mktime argument out of range - on very specific time

Marc-Andre Lemburg report at bugs.python.org
Fri Apr 15 13:35:53 CEST 2011


Marc-Andre Lemburg <mal at egenix.com> added the comment:

JoeKuan wrote:
> 
> New submission from JoeKuan <kuan.joe at gmail.com>:
> 
>>>> a = (1970, 1, 1, 0, 59, 58, 0, 0, 0)
>>>> time.mktime(a)
> -2.0

On Windows, you get an OverflowError for this tuple as well.

>>>> a = (1970, 1, 1, 0, 59, 59, 0, 0, 0)
>>>> time.mktime(a)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> OverflowError: mktime argument out of range
> 
>>>> a = (1970, 1, 1, 1, 0, 0, 0, 0, 0)
>>>> time.mktime(a)
> 0.0
> 
>>>> a = (1970, 1, 1, 0, 59, 60, 0, 0, 0)
>>>> time.mktime(a)
> 0.0

Note that time.mktime() is direct interface to the C lib
funtion of the same name. As a result, the support for
the various values is platform dependent. In general,
dates before the epoch tend not to work or give wrong
results.

Since mktime() works on local time, the time zone
in affect on 1970-01-01 matters and that's why you are
seeing the OverflowError even for values after
1970-01-01 00:00:00.

----------
nosy: +lemburg
title: mktime - OverflowError: mktime argument out of range - on very specific time -> mktime - OverflowError: mktime argument out of range -	on very specific time

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11850>
_______________________________________


More information about the Python-bugs-list mailing list