]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133940: test_strftime incorrectly calculates expected week (GH-134281)
authorGustaf <79180496+GGyll@users.noreply.github.com>
Tue, 20 May 2025 00:54:48 +0000 (20:54 -0400)
committerGitHub <noreply@github.com>
Tue, 20 May 2025 00:54:48 +0000 (17:54 -0700)
Let the system determine the correct tm_wday and tm_isdst.

Lib/test/test_strftime.py

index 752e31359cf20620cc517d18810afe480ce36072..375f6aaedd89349370c13817df562cc7ffd3fe7e 100644 (file)
@@ -39,7 +39,21 @@ class StrftimeTest(unittest.TestCase):
         if now[3] < 12: self.ampm='(AM|am)'
         else: self.ampm='(PM|pm)'
 
-        self.jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0)))
+        jan1 = time.struct_time(
+            (
+                now.tm_year,  # Year
+                1,  # Month (January)
+                1,  # Day (1st)
+                0,  # Hour (0)
+                0,  # Minute (0)
+                0,  # Second (0)
+                -1,  # tm_wday (will be determined)
+                1,  # tm_yday (day 1 of the year)
+                -1,  # tm_isdst (let the system determine)
+            )
+        )
+        # use mktime to get the correct tm_wday and tm_isdst values
+        self.jan1 = time.localtime(time.mktime(jan1))
 
         try:
             if now[8]: self.tz = time.tzname[1]