This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Martin.Morrison
Recipients Martin.Morrison
Date 2012-02-29.11:57:47
SpamBayes Score 4.097595e-10
Marked as misclassified No
Message-id <1330516668.55.0.549591415618.issue14157@psf.upfronthosting.co.za>
In-reply-to
Content
time.strptime without a year fails on Feb 29 with:

>>> time.strptime("Feb 29", "%b %d")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/_strptime.py", line 454, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.6/_strptime.py", line 440, in _strptime
    datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month

This is due to the use of "1900" as the default year when parsing. It would be nice to have an optional "defaults" keyword argument to the strptime function that can be used to override the defaults, thus allowing leap year dates to be parsed without specifying the date.

(Note: the code in question attempted to set the year *after* the parse so that ultimately there is a valid struct_time, but since the parse never succeeds, this can't work).
History
Date User Action Args
2012-02-29 11:57:48Martin.Morrisonsetrecipients: + Martin.Morrison
2012-02-29 11:57:48Martin.Morrisonsetmessageid: <1330516668.55.0.549591415618.issue14157@psf.upfronthosting.co.za>
2012-02-29 11:57:47Martin.Morrisonlinkissue14157 messages
2012-02-29 11:57:47Martin.Morrisoncreate