Bug in time module?

Berthold Höllmann se6y095 at public.uni-hamburg.de
Wed Sep 8 03:55:58 EDT 1999


lec <englim at pc.jaring.my> writes:

> Is this considered a bug since there is no Feb 31, 1999 or Feb 29, 1999?
> 
> >>> import time
> >>> time.strptime('31/02/1999', "%d/%m/%Y")
> (1999, 2, 31, 0, 0, 0, 2, 62, 0)
> >>> time.asctime(time.strptime('31/02/1999', "%d/%m/%Y"))
> 'Wed Feb 31 00:00:00 1999'
> >>> time.strptime('29/02/1999', "%d/%m/%Y")
> (1999, 2, 29, 0, 0, 0, 0, 60, 0)
> >>> time.asctime(time.strptime('29/02/1999', "%d/%m/%Y"))
> 'Mon Feb 29 00:00:00 1999'

More very strange things happen for me on linux:

Python 1.5.2 (#2, Apr 22 1999, 14:34:42)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import time
>>> time.strptime('31/02/1999', "%d/%m/%Y")
(1999, 2, 31, 0, 0, 0, 6, 1, 0)
>>> time.asctime(time.strptime('31/02/1999', "%d/%m/%Y"))
'Sun Feb 31 00:00:00 1999'
>>> time.strptime('29/02/1999', "%d/%m/%Y")
(1999, 2, 29, 0, 0, 0, 6, 1, 0)
>>> time.asctime(time.strptime('29/02/1999', "%d/%m/%Y"))
'Sun Feb 29 00:00:00 1999'
>>> time.asctime(time.strptime('28/02/1999', "%d/%m/%Y"))
'Sun Feb 28 00:00:00 1999'
>>> time.asctime(time.strptime('27/02/1999', "%d/%m/%Y"))
'Sun Feb 27 00:00:00 1999'
>>> time.asctime(time.strptime('26/02/1999', "%d/%m/%Y"))
'Sun Feb 26 00:00:00 1999'
>>> time.asctime(time.strptime('02/02/1999', "%d/%m/%Y"))
'Sun Feb  2 00:00:00 1999'
>>> time.asctime(time.strptime('01/02/1999', "%d/%m/%Y"))
'Sun Feb  1 00:00:00 1999'
>>> time.asctime(time.strptime('08/09/1999', "%d/%m/%Y"))
'Sun Sep  8 00:00:00 1999'
>>> time.asctime(time.strptime('08/09/1998', "%d/%m/%Y"))
'Sun Sep  8 00:00:00 1998'
>>> 

Everyday is sunday using Python? Really great.

Cheers

Berthold
-- 
bhoel at starship.python.net / http://starship.python.net/crew/bhoel/
        It is unlawful to use this email address for unsolicited ads
        (USC Title 47 Sec.227). I will assess a US$500 charge for
        reviewing and deleting each unsolicited ad.




More information about the Python-list mailing list