https://github.com/python/cpython/commit/783675e73f78ace7dc9fc318726f726de2a15855
commit: 783675e73f78ace7dc9fc318726f726de2a15855
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: gpshead <g...@krypto.org>
date: 2025-05-20T01:17:22Z
summary:

[3.13] gh-133940: test_strftime incorrectly calculates expected week 
(GH-134281) (#134302)

gh-133940: test_strftime incorrectly calculates expected week (GH-134281)

Let the system determine the correct tm_wday and tm_isdst.
(cherry picked from commit e3dda8f81832008adf19906004f0cd53de95dd0b)

Co-authored-by: Gustaf <79180496+gg...@users.noreply.github.com>

files:
M Lib/test/test_strftime.py

diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index cebfc8927862a7..f77b354c391944 100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -39,7 +39,21 @@ def _update_variables(self, now):
         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]

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to