Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f1b2ba6

Browse files
committed
Fix logic error introduced in last commit. Also add a comment to explain what
the code is doing.
1 parent c203370 commit f1b2ba6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/_strptime.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ def __calc_date_time(self):
147147
# strings (e.g., MacOS 9 having timezone as ('','')).
148148
if old:
149149
current_format = current_format.replace(old, new)
150+
# If %W is used, then Sunday, 2005-01-03 will fall on week 0 since
151+
# 2005-01-03 occurs before the first Monday of the year. Otherwise
152+
# %U is used.
150153
time_tuple = time.struct_time((1999,1,3,1,1,1,6,3,0))
151154
if '00' in time.strftime(directive, time_tuple):
152-
U_W = '%U'
153-
else:
154155
U_W = '%W'
156+
else:
157+
U_W = '%U'
155158
date_time[offset] = current_format.replace('11', U_W)
156159
self.LC_date_time = date_time[0]
157160
self.LC_date = date_time[1]

0 commit comments

Comments
 (0)