Bug in time module?

Gerrit Holl gerrit.holl at pobox.com
Wed Sep 8 15:17:49 EDT 1999


On Wed, Sep 08, 1999 at 12:13:20PM +0800, lec wrote:
> 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'
> 

>>> time.strptime('31/12/2040', "%d/%m/%Y")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: unconverted data remains: '0'
>>> time.strptime('31/12/2036', "%d/%m/%Y")
(2036, 12, 31, 0, 0, 0, 6, 1, 0)
>>> time.strptime('31/12/2037', "%d/%m/%Y")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: format mismatch

regards,
Gerrit.
-- 
Unix is easy: type 'man man' and the rest comes of itself.




More information about the Python-list mailing list