]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix logic error introduced in last commit. Also add a comment to explain what
authorBrett Cannon <bcannon@gmail.com>
Mon, 29 Aug 2005 18:25:55 +0000 (18:25 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 29 Aug 2005 18:25:55 +0000 (18:25 +0000)
the code is doing.

Lib/_strptime.py

index aa02ba12c831cc85c0e84e5b484a0389e10807d5..90928ffca8d28938febdefdd44d824a82c9a78e7 100644 (file)
@@ -147,11 +147,14 @@ class LocaleTime(object):
                 # strings (e.g., MacOS 9 having timezone as ('','')).
                 if old:
                     current_format = current_format.replace(old, new)
+            # If %W is used, then Sunday, 2005-01-03 will fall on week 0 since
+            # 2005-01-03 occurs before the first Monday of the year.  Otherwise
+            # %U is used.
             time_tuple = time.struct_time((1999,1,3,1,1,1,6,3,0))
             if '00' in time.strftime(directive, time_tuple):
-                U_W = '%U'
-            else:
                 U_W = '%W'
+            else:
+                U_W = '%U'
             date_time[offset] = current_format.replace('11', U_W)
         self.LC_date_time = date_time[0]
         self.LC_date = date_time[1]