From 629ff02cd4593b68bf4476bb78b660395aee191e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 17 Oct 2024 20:36:22 +0300 Subject: [PATCH 1/3] gh-52551: Use wcsftime() to implement time.strftime() on Windows --- .../next/Library/2024-10-17-20-36-06.gh-issue-52551.EIVNYY.rst | 1 + Modules/timemodule.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-10-17-20-36-06.gh-issue-52551.EIVNYY.rst diff --git a/Misc/NEWS.d/next/Library/2024-10-17-20-36-06.gh-issue-52551.EIVNYY.rst b/Misc/NEWS.d/next/Library/2024-10-17-20-36-06.gh-issue-52551.EIVNYY.rst new file mode 100644 index 00000000000000..48d3d93c3d72af --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-17-20-36-06.gh-issue-52551.EIVNYY.rst @@ -0,0 +1 @@ +Use :c:func:`!wcsftime` to implement :func:`time.strftime` on Windows. diff --git a/Modules/timemodule.c b/Modules/timemodule.c index b9d114ada0dfcd..3ca21bada842f6 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -740,8 +740,7 @@ checktm(struct tm* buf) } #ifdef MS_WINDOWS - /* wcsftime() doesn't format correctly time zones, see issue #10653 */ -# undef HAVE_WCSFTIME +# define HAVE_WCSFTIME #endif #define STRFTIME_FORMAT_CODES \ "Commonly used format codes:\n\ From 0c0f98781681430ba3daaa9b50d2c84d5f8c89d7 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 17 Oct 2024 21:09:01 +0300 Subject: [PATCH 2/3] Fix test. --- Lib/test/test_strftime.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index cebfc8927862a7..752e31359cf206 100644 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -183,8 +183,7 @@ class Y1900Tests(unittest.TestCase): def test_y_before_1900(self): # Issue #13674, #19634 t = (1899, 1, 1, 0, 0, 0, 0, 0, 0) - if (sys.platform == "win32" - or sys.platform.startswith(("aix", "sunos", "solaris"))): + if sys.platform.startswith(("aix", "sunos", "solaris")): with self.assertRaises(ValueError): time.strftime("%y", t) else: From 16782e9315b02c4e52cf5679235979aa5f3f243a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 18 Oct 2024 16:23:14 +0300 Subject: [PATCH 3/3] HAVE_WCSFTIME is already defined. --- Modules/timemodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 3ca21bada842f6..340011fc08b551 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -739,9 +739,6 @@ checktm(struct tm* buf) return 1; } -#ifdef MS_WINDOWS -# define HAVE_WCSFTIME -#endif #define STRFTIME_FORMAT_CODES \ "Commonly used format codes:\n\ \n\