From 92929d826598c69a14530455b9561107b9bf2847 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sun, 26 Oct 2025 16:55:36 -0700 Subject: [PATCH 01/20] provide support for %F token in strptime; add test for it and %T --- Lib/_strptime.py | 2 ++ Lib/test/test_strptime.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index d011ddf8b181c3..17221b925e177c 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -418,6 +418,8 @@ def __init__(self, locale_time=None): mapping['W'] = mapping['U'].replace('U', 'W') base.__init__(mapping) + # %F %T %R %r %X %x %c (some shorthands and locales) + base.__setitem__('F', self.pattern('%Y-%m-%d')) base.__setitem__('T', self.pattern('%H:%M:%S')) base.__setitem__('R', self.pattern('%H:%M')) base.__setitem__('r', self.pattern(self.locale_time.LC_time_ampm)) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 40e114aada67eb..3c97f94ab4b7cd 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -649,6 +649,32 @@ def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): time.strptime("Feb 29", "%b %d"), time.strptime("Mar 1", "%b %d")) + def test_shorthand_year_month_day(self): + # Test that token '%F' is equivalent to '%Y-%m-%d' + formats = dict(short="%F",long="%Y-%m-%d") + test_date = "2025-10-26" + shorthand = time.strptime(test_date,formats["short"]) + long_hand = time.strptime(test_date,formats["long"]) + self.assertEqual(shorthand,long_hand) + # ensure datetime functionality + import datetime + shorthand = datetime.datetime.strptime(test_date,formats["short"]) + long_hand = datetime.datetime.strptime(test_date,formats["long"]) + assert shorthand == long_hand + + def test_shorthand_hour_minute_second(self): + # Test that token '%T' is equivalent to '%H:%M:%S' + formats = dict(short="%T",long="%H:%M:%S") + test_time = "15:00:00" + shorthand = time.strptime(test_time,formats["short"]) + long_hand = time.strptime(test_time,formats["long"]) + self.assertEqual(shorthand,long_hand) + # ensure datetime functionality + import datetime + shorthand = datetime.datetime.strptime(test_time,formats["short"]) + long_hand = datetime.datetime.strptime(test_time,formats["long"]) + assert shorthand == long_hand + class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" From b1bf9b4e9b9424e5500bc6e9340559b75bc14aa4 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 00:13:05 +0000 Subject: [PATCH 02/20] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst new file mode 100644 index 00000000000000..b1bd5d9b28f3d9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst @@ -0,0 +1 @@ +Add `'%F'` support to `datetime.datetime.strptime`, a C99+ `time.h` format token. From d84fd544ddcf11853882fd583a1c2d4777e52eaa Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:10:06 -0700 Subject: [PATCH 03/20] rm comment as recommended Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Lib/_strptime.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index 17221b925e177c..8b62ea734b7d11 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -418,7 +418,6 @@ def __init__(self, locale_time=None): mapping['W'] = mapping['U'].replace('U', 'W') base.__init__(mapping) - # %F %T %R %r %X %x %c (some shorthands and locales) base.__setitem__('F', self.pattern('%Y-%m-%d')) base.__setitem__('T', self.pattern('%H:%M:%S')) base.__setitem__('R', self.pattern('%H:%M')) From cb8d7d3d6d4ff1f9f3629d769474b1349173ba35 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:10:55 -0700 Subject: [PATCH 04/20] Update Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- .../next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst index b1bd5d9b28f3d9..0cf1830e82bdae 100644 --- a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst +++ b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst @@ -1 +1 @@ -Add `'%F'` support to `datetime.datetime.strptime`, a C99+ `time.h` format token. +Add `'%F'` support to :meth:`~datetime.datetime.strptime`, a C99+ ``time.h`` format code. From 634eceaf40bd681478d8a8ac8a0c5d1328c04b8f Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:13:59 -0700 Subject: [PATCH 05/20] Rename NEWS blurbit to match new github issue name --- ....WkozE0.rst => 2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Library/{2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst => 2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst} (100%) diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst similarity index 100% rename from Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140644.WkozE0.rst rename to Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst From 2e940376645defcc50bb65e226dd47f0aa4d310e Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:19:02 -0700 Subject: [PATCH 06/20] Update test_strptime.py to use unittest methods, as requested --- Lib/test/test_strptime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 3c97f94ab4b7cd..2182ba755b3f50 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -660,7 +660,7 @@ def test_shorthand_year_month_day(self): import datetime shorthand = datetime.datetime.strptime(test_date,formats["short"]) long_hand = datetime.datetime.strptime(test_date,formats["long"]) - assert shorthand == long_hand + self.assertEqual(shorthand,long_hand) def test_shorthand_hour_minute_second(self): # Test that token '%T' is equivalent to '%H:%M:%S' @@ -673,7 +673,7 @@ def test_shorthand_hour_minute_second(self): import datetime shorthand = datetime.datetime.strptime(test_time,formats["short"]) long_hand = datetime.datetime.strptime(test_time,formats["long"]) - assert shorthand == long_hand + self.assertEqual(shorthand,long_hand) class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" From c23b7318cf58028ed16056a308d72895074d0128 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:36:01 -0700 Subject: [PATCH 07/20] simplify news per recommendation Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- .../next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst index 0cf1830e82bdae..19d281c7cc9c49 100644 --- a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst +++ b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst @@ -1 +1 @@ -Add `'%F'` support to :meth:`~datetime.datetime.strptime`, a C99+ ``time.h`` format code. +Add `'%F'` support to :meth:`~datetime.datetime.strptime`. From e77ff968e3a3e6bca3e90acde00a9a5c1f41bb85 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:37:13 -0700 Subject: [PATCH 08/20] Remove datetime tests from test_strptime.py (added to `datetimetester.py` instead) --- Lib/test/test_strptime.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 2182ba755b3f50..02617a58130335 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -656,11 +656,6 @@ def test_shorthand_year_month_day(self): shorthand = time.strptime(test_date,formats["short"]) long_hand = time.strptime(test_date,formats["long"]) self.assertEqual(shorthand,long_hand) - # ensure datetime functionality - import datetime - shorthand = datetime.datetime.strptime(test_date,formats["short"]) - long_hand = datetime.datetime.strptime(test_date,formats["long"]) - self.assertEqual(shorthand,long_hand) def test_shorthand_hour_minute_second(self): # Test that token '%T' is equivalent to '%H:%M:%S' @@ -669,11 +664,6 @@ def test_shorthand_hour_minute_second(self): shorthand = time.strptime(test_time,formats["short"]) long_hand = time.strptime(test_time,formats["long"]) self.assertEqual(shorthand,long_hand) - # ensure datetime functionality - import datetime - shorthand = datetime.datetime.strptime(test_time,formats["short"]) - long_hand = datetime.datetime.strptime(test_time,formats["long"]) - self.assertEqual(shorthand,long_hand) class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" From ffbc21513046d84d51b834feba12798498c321aa Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Tue, 28 Oct 2025 14:42:15 -0700 Subject: [PATCH 09/20] Tests moved to datetimetester.py --- Lib/test/datetimetester.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 7df27206206268..6abb704f08865f 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1212,6 +1212,20 @@ def test_strptime_leap_year(self): date.strptime('20-03-14', '%y-%m-%d') date.strptime('02-29,2024', '%m-%d,%Y') + def test_strptime_C99_shorthand_year_month_day(self): + formats = dict(short="%F",long="%Y-%m-%d") + test_date = "2025-10-26" + shorthand = datetime.strptime(test_date,formats["short"]) + long_hand = datetime.strptime(test_date,formats["long"]) + self.assertEqual(shorthand,long_hand) + + def test_strptime_C99_shorthand_hour_minute_second(self): + formats = dict(short="%T",long="%H:%M:%S") + test_time = "15:00:00" + shorthand = datetime.strptime(test_time,formats["short"]) + long_hand = datetime.strptime(test_time,formats["long"]) + self.assertEqual(shorthand,long_hand) + class SubclassDate(date): sub_var = 1 From ff10b73bb2125686b8de10a3ad2bf4f0fc4ad0f5 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Sat, 7 Feb 2026 15:24:04 -0700 Subject: [PATCH 10/20] Update Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- .../next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst index 19d281c7cc9c49..c2bb69b894c1dd 100644 --- a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst +++ b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst @@ -1 +1 @@ -Add `'%F'` support to :meth:`~datetime.datetime.strptime`. +Add ``'%F'`` support to :meth:`~datetime.datetime.strptime`. From b4ec5f888b7ac3642009a59bbd3fe0b924e715ee Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Sat, 7 Feb 2026 15:24:36 -0700 Subject: [PATCH 11/20] Update Lib/test/test_strptime.py Remove extra comments Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Lib/test/test_strptime.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 02617a58130335..5ef682bc640975 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -650,7 +650,6 @@ def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): time.strptime("Mar 1", "%b %d")) def test_shorthand_year_month_day(self): - # Test that token '%F' is equivalent to '%Y-%m-%d' formats = dict(short="%F",long="%Y-%m-%d") test_date = "2025-10-26" shorthand = time.strptime(test_date,formats["short"]) From 8513e1d63726b9ea98d8786507e3f0b26ad6d692 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Sat, 7 Feb 2026 15:24:51 -0700 Subject: [PATCH 12/20] Update Lib/test/datetimetester.py shorten test name Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Lib/test/datetimetester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index a5c963e4929a55..998132de547f0e 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1212,7 +1212,7 @@ def test_strptime_leap_year(self): date.strptime('20-03-14', '%y-%m-%d') date.strptime('02-29,2024', '%m-%d,%Y') - def test_strptime_C99_shorthand_year_month_day(self): + def test_strptime_F_format(self): formats = dict(short="%F",long="%Y-%m-%d") test_date = "2025-10-26" shorthand = datetime.strptime(test_date,formats["short"]) From 0a928e6487f0da392f7f68a3f5331d8d82f6286c Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Sat, 7 Feb 2026 15:25:10 -0700 Subject: [PATCH 13/20] Update Lib/test/datetimetester.py shorten test function name Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Lib/test/datetimetester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 998132de547f0e..e8c2525203a46a 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1219,7 +1219,7 @@ def test_strptime_F_format(self): long_hand = datetime.strptime(test_date,formats["long"]) self.assertEqual(shorthand,long_hand) - def test_strptime_C99_shorthand_hour_minute_second(self): + def test_strptime_T_format(self): formats = dict(short="%T",long="%H:%M:%S") test_time = "15:00:00" shorthand = datetime.strptime(test_time,formats["short"]) From 029ed4f598144df4524653faba8f9754d6fa7958 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 7 Feb 2026 15:30:34 -0700 Subject: [PATCH 14/20] refactor test for %F as requested --- Lib/test/test_strptime.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 5ef682bc640975..5e08ac033fb328 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -650,11 +650,11 @@ def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): time.strptime("Mar 1", "%b %d")) def test_shorthand_year_month_day(self): - formats = dict(short="%F",long="%Y-%m-%d") test_date = "2025-10-26" - shorthand = time.strptime(test_date,formats["short"]) - long_hand = time.strptime(test_date,formats["long"]) - self.assertEqual(shorthand,long_hand) + self.assertEqual( + time.strptime(test_date,"%F"), + time.strptime(test_date,"%Y-%m-%d") + ) def test_shorthand_hour_minute_second(self): # Test that token '%T' is equivalent to '%H:%M:%S' From 88c6f029f096955fb570a4b6847eabce9e9f4aa9 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 7 Feb 2026 15:54:25 -0700 Subject: [PATCH 15/20] refactor test for %F and %T as requested --- Lib/test/datetimetester.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index e8c2525203a46a..2d11e92c5337dc 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1213,18 +1213,18 @@ def test_strptime_leap_year(self): date.strptime('02-29,2024', '%m-%d,%Y') def test_strptime_F_format(self): - formats = dict(short="%F",long="%Y-%m-%d") test_date = "2025-10-26" - shorthand = datetime.strptime(test_date,formats["short"]) - long_hand = datetime.strptime(test_date,formats["long"]) - self.assertEqual(shorthand,long_hand) + self.assertEqual( + datetime.strptime(test_date,"%F"), + datetime.strptime(test_date,"%Y-%m-%d") + ) def test_strptime_T_format(self): - formats = dict(short="%T",long="%H:%M:%S") test_time = "15:00:00" - shorthand = datetime.strptime(test_time,formats["short"]) - long_hand = datetime.strptime(test_time,formats["long"]) - self.assertEqual(shorthand,long_hand) + self.assertEqual( + datetime.strptime(test_time,"%T"), + datetime.strptime(test_time,"%H:%M:%S") + ) class SubclassDate(date): sub_var = 1 From 707ea087cdf0c1c9616c72706cfbc7bc29dfca6c Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 7 Feb 2026 15:54:52 -0700 Subject: [PATCH 16/20] refactor test %T as requested; rename %F + %T tests to match datetimetester request --- Lib/test/test_strptime.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 5e08ac033fb328..838ff0bc4af3d5 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -649,20 +649,19 @@ def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): time.strptime("Feb 29", "%b %d"), time.strptime("Mar 1", "%b %d")) - def test_shorthand_year_month_day(self): + def test_strptime_F_format(self): test_date = "2025-10-26" self.assertEqual( time.strptime(test_date,"%F"), time.strptime(test_date,"%Y-%m-%d") ) - def test_shorthand_hour_minute_second(self): - # Test that token '%T' is equivalent to '%H:%M:%S' - formats = dict(short="%T",long="%H:%M:%S") + def test_strptime_T_format(self): test_time = "15:00:00" - shorthand = time.strptime(test_time,formats["short"]) - long_hand = time.strptime(test_time,formats["long"]) - self.assertEqual(shorthand,long_hand) + self.assertEqual( + time.strptime(test_time,"%T"), + time.strptime(test_time,"%H:%M:%S") + ) class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" From c61cb2f6bfd876829dd15da857e3b4c1e378812c Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 7 Feb 2026 15:55:35 -0700 Subject: [PATCH 17/20] add %F and %T tests, as requested, for ensuring strptime & strftime token symmetry --- Lib/test/test_time.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index c360f4a64c266b..da0cf494bfa8ad 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -358,8 +358,8 @@ def test_strptime(self): # Should be able to go round-trip from strftime to strptime without # raising an exception. tt = time.gmtime(self.t) - for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', - 'j', 'm', 'M', 'p', 'S', + for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'F', 'H', 'I', + 'j', 'm', 'M', 'p', 'S', 'T', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): format = '%' + directive if directive == 'd': From 10ab774139485d983c120f4a996a543eff022823 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 7 Feb 2026 16:02:13 -0700 Subject: [PATCH 18/20] remove (0) note for %F in documentation, as requested --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 3ab3450032abe4..bdb650aae9d0be 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2540,7 +2540,7 @@ requires, and these work on all supported platforms. | ``%e`` | The day of the month as a | ␣1, ␣2, ..., 31 | | | | space-padded decimal number. | | | +-----------+--------------------------------+------------------------+-------+ -| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | \(0) | +| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-26, | | | | the ISO 8601 format. | 1001-12-30 | | +-----------+--------------------------------+------------------------+-------+ | ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | \(0) | From 179afae875fdf14e09b77379ed3ecea70ffb98cc Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sun, 8 Feb 2026 07:33:32 -0700 Subject: [PATCH 19/20] revert date change in --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index bdb650aae9d0be..429b728dfead5a 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2540,7 +2540,7 @@ requires, and these work on all supported platforms. | ``%e`` | The day of the month as a | ␣1, ␣2, ..., 31 | | | | space-padded decimal number. | | | +-----------+--------------------------------+------------------------+-------+ -| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-26, | | +| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | | | | the ISO 8601 format. | 1001-12-30 | | +-----------+--------------------------------+------------------------+-------+ | ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | \(0) | From f56f54a1d56b2fe4c53789257f923e62faa59009 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sun, 8 Feb 2026 07:34:47 -0700 Subject: [PATCH 20/20] documenting %F addition to strptime --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 429b728dfead5a..a3537d9aff8f6a 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2676,7 +2676,7 @@ differences between platforms in handling of unsupported format specifiers. ``%:z`` was added for :meth:`~.datetime.strftime` .. versionadded:: 3.15 - ``%:z`` was added for :meth:`~.datetime.strptime` + ``%:z`` and ``%F`` were added for :meth:`~.datetime.strptime` Technical Detail ^^^^^^^^^^^^^^^^