summaryrefslogtreecommitdiffstats
path: root/Lib/_strptime.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-12 08:51:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-12 08:51:16 (GMT)
commit8a7240eeed609f747bdf38985679816ed9f61a0e (patch)
tree792f7cecbe5cd15b29433d8f7acb3023f89325ef /Lib/_strptime.py
parentd7569637b53d457423d47e83bd9ec35ce1aba772 (diff)
downloadcpython-8a7240eeed609f747bdf38985679816ed9f61a0e.zip
cpython-8a7240eeed609f747bdf38985679816ed9f61a0e.tar.gz
cpython-8a7240eeed609f747bdf38985679816ed9f61a0e.tar.bz2
Issue #23718: Fixed parsing time in week 0 before Jan 1. Original patch by
Tamás Bence Gedai.
Diffstat (limited to 'Lib/_strptime.py')
-rw-r--r--Lib/_strptime.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index b8cda76..f84227b 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -462,6 +462,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
week_starts_Mon = True if week_of_year_start == 0 else False
julian = _calc_julian_from_U_or_W(year, week_of_year, weekday,
week_starts_Mon)
+ if julian <= 0:
+ year -= 1
+ yday = 366 if calendar.isleap(year) else 365
+ julian += yday
# Cannot pre-calculate datetime_date() since can change in Julian
# calculation and thus could have different value for the day of the week
# calculation.