diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-10 18:17:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-10 18:17:46 (GMT) |
commit | 1682e5d74080d88109b3fc54e2ddfa762feb3e1d (patch) | |
tree | f12a24b81302f643264728357956909d5d8f2a8c /Lib/_strptime.py | |
parent | a9494f6c53b9b69063f0f304062a6a6bf013e47a (diff) | |
download | cpython-1682e5d74080d88109b3fc54e2ddfa762feb3e1d.zip cpython-1682e5d74080d88109b3fc54e2ddfa762feb3e1d.tar.gz cpython-1682e5d74080d88109b3fc54e2ddfa762feb3e1d.tar.bz2 |
Issue #14157: Fix time.strptime failing without a year on February 29th.
Patch by Hynek Schlawack.
Diffstat (limited to 'Lib/_strptime.py')
-rw-r--r-- | Lib/_strptime.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py index 0ea4c43..0106e91 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -339,7 +339,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"): raise ValueError("unconverted data remains: %s" % data_string[found.end():]) - year = 1900 + year = None month = day = 1 hour = minute = second = fraction = 0 tz = -1 @@ -444,6 +444,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"): else: tz = value break + if year is None and month == 2 and day == 29: + year = 1904 # 1904 is first leap year of 20th century + elif year is None: + year = 1900 # If we know the week of the year and what day of that week, we can figure # out the Julian day of the year. if julian == -1 and week_of_year != -1 and weekday != -1: |