Skip to content

Commit dca9e51

Browse files
committed
Fix erroneous and misleading example Doc to %y from %Y, use correct C99+ definition for C99 %D; update additional tests
1 parent b3f67ca commit dca9e51

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Doc/library/datetime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,7 @@ requires, and these work on all supported platforms.
25342534
| ``%d`` | Day of the month as a | 01, 02, ..., 31 | \(9) |
25352535
| | zero-padded decimal number. | | |
25362536
+-----------+--------------------------------+------------------------+-------+
2537-
| ``%D`` | Equivalent to ``%m/%d/%y``. | 11/28/2025 | \(9) |
2537+
| ``%D`` | Equivalent to ``%m/%d/%y``. | 11/28/25 | \(9) |
25382538
| | | | |
25392539
+-----------+--------------------------------+------------------------+-------+
25402540
| ``%e`` | The day of the month as a | ␣1, ␣2, ..., 31 | |

Lib/_strptime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def __init__(self, locale_time=None):
425425
base.__setitem__('X', self.pattern(self.locale_time.LC_time))
426426
base.__setitem__('x', self.pattern(self.locale_time.LC_date))
427427
base.__setitem__('c', self.pattern(self.locale_time.LC_date_time))
428-
base.__setitem__('D', self.pattern('%m/%d/%Y'))
428+
base.__setitem__('D', self.pattern('%m/%d/%y'))
429429

430430
def __seqToRE(self, to_convert, directive, altregex=None):
431431
"""Convert a list to a regex string for matching a directive.

Lib/test/datetimetester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,10 +2201,10 @@ def test_strptime_F_format(self):
22012201
)
22022202

22032203
def test_strptime_D_format(self):
2204-
test_date = "11/28/2025"
2204+
test_date = "11/28/25"
22052205
self.assertEqual(
22062206
self.theclass.strptime(test_date, "%D"),
2207-
self.theclass.strptime(test_date, "%m/%d/%Y")
2207+
self.theclass.strptime(test_date, "%m/%d/%y")
22082208
)
22092209

22102210

Lib/test/test_strptime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ def test_strptime_T_format(self):
664664
)
665665

666666
def test_strptime_D_format(self):
667-
test_date = "11/28/2025"
667+
test_date = "11/28/25"
668668
self.assertEqual(
669669
time.strptime(test_date, "%D"),
670-
time.strptime(test_date, "%m/%d/%Y")
670+
time.strptime(test_date, "%m/%d/%y")
671671
)
672672

673673
class Strptime12AMPMTests(unittest.TestCase):

0 commit comments

Comments
 (0)