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 | c2b714ce216bb0c844e3d4c3440937b82a924e3d (patch) | |
tree | 4ed31322b2e39ede48225c97984dac05aae1efaa /Lib/_strptime.py | |
parent | 35d03ed832cb7f3127794b218aac86fae93b8354 (diff) | |
download | cpython-c2b714ce216bb0c844e3d4c3440937b82a924e3d.zip cpython-c2b714ce216bb0c844e3d4c3440937b82a924e3d.tar.gz cpython-c2b714ce216bb0c844e3d4c3440937b82a924e3d.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 | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py index d9563b9..720fea8 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -326,7 +326,8 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"): if len(data_string) != found.end(): raise ValueError("unconverted data remains: %s" % data_string[found.end():]) - year = 1900 + + year = None month = day = 1 hour = minute = second = fraction = 0 tz = -1 @@ -425,6 +426,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: |