mktime() ???

Fredrik Lundh fredrik at pythonware.com
Mon Nov 29 09:54:04 EST 1999


Przemys³aw G. Gawroñski <gawron at obop.com.pl> wrote:
> In library reference it's writen, that mktime from time module raises an
> exeption when it cann't construct a correct time from a tuple parameter.
>
> I tryied the following:
>
> mktime((1999, 23, 29, 0, 0, 0, 0, 0, 0 ))
>
> (the month number is incorect),
>
> and
>
> mktime((1999, 23, 49, 0, 0, 0, 0, 0, 0 ))
>
> (the month, and day aren't correct).
>
> Well, neither one of them has raised an exeption.
>
> Is it a bug or am'I not understanding somthing in the docs ?

well, it sure looks like the C library on your computer
thinks it can construct a correct time from the given
tuple.

my Linux box doesn't mind, for example:

>>> import time
>>> t = time.mktime((1999, 23, 49, 0, 0, 0, 0, 0, 0))
>>> time.localtime(t)
(2000, 12, 19, 0, 0, 0, 1, 354, 0)

in fact, I cannot find a single platform that considers
this as an error.  it's actually documented behaviour,
at least on Solaris:

    The original values of the components may be either  greater
     than  or  less  than  the  specified  range.  For example, a
     tm_hour of -1 means 1 hour before  midnight,  tm_mday  of  0
     means  the day preceding the current month, and tm_mon of -2
     means 2 months before January of tm_year.

which seems to be exactly how most Unix and Windows
boxes behave.  maybe the library reference should be
updated?

</F>





More information about the Python-list mailing list