Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify and make %C logic consistent
  • Loading branch information
jyalim committed Mar 31, 2026
commit c2ef2610c13a2bda45367aa1bc0b089dd4f3acb3
5 changes: 0 additions & 5 deletions Lib/_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,6 @@ def parse_int(s):
# C99 support for century in [0,99] (years 0-9999).
century = parse_int(found_dict[group_key])
year = century * 100
if century > 0:
year = century * 100
elif century == 0:
# ValueError fix, since MINYEAR = 1 in Lib/_pydatetime.py
year = 1
elif group_key == 'Y':
year = int(found_dict['Y'])
elif group_key == 'G':
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -2226,9 +2226,9 @@ def test_strptime_n_and_t_format(self):
)

def test_strptime_C_format(self):
# verify cent. 0, zero-padding, modern cent., last supported cent.
for c in ('0', '01', '20', '99'):
expected_year = int(c) * 100 if int(c) != 0 else 1
# verify zero-padding, modern cent., last supported cent.
for c in ('01', '20', '99'):
expected_year = int(c) * 100
with self.subTest(format_directive="C", century=c):
self.assertEqual(
self.theclass.strptime(c, "%C"),
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ def test_strptime_n_and_t_format(self):
)

def test_strptime_C_format(self):
# verify cent. 0, zero-padding, modern cent., last supported cent.
for c in ('0', '01', '20', '99'):
expected_year = int(c) * 100 if int(c) != 0 else 1
# verify zero-padding, modern cent., last supported cent.
for c in ('01', '20', '99'):
expected_year = int(c) * 100
with self.subTest(format_directive="C", century=c):
self.assertEqual(
time.strptime(c, "%C"),
Expand Down
Loading