Skip to content

Commit c2ef261

Browse files
committed
simplify and make %C logic consistent
1 parent 77280db commit c2ef261

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Lib/_strptime.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,6 @@ def parse_int(s):
621621
# C99 support for century in [0,99] (years 0-9999).
622622
century = parse_int(found_dict[group_key])
623623
year = century * 100
624-
if century > 0:
625-
year = century * 100
626-
elif century == 0:
627-
# ValueError fix, since MINYEAR = 1 in Lib/_pydatetime.py
628-
year = 1
629624
elif group_key == 'Y':
630625
year = int(found_dict['Y'])
631626
elif group_key == 'G':

Lib/test/datetimetester.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,9 +2226,9 @@ def test_strptime_n_and_t_format(self):
22262226
)
22272227

22282228
def test_strptime_C_format(self):
2229-
# verify cent. 0, zero-padding, modern cent., last supported cent.
2230-
for c in ('0', '01', '20', '99'):
2231-
expected_year = int(c) * 100 if int(c) != 0 else 1
2229+
# verify zero-padding, modern cent., last supported cent.
2230+
for c in ('01', '20', '99'):
2231+
expected_year = int(c) * 100
22322232
with self.subTest(format_directive="C", century=c):
22332233
self.assertEqual(
22342234
self.theclass.strptime(c, "%C"),

Lib/test/test_strptime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,9 @@ def test_strptime_n_and_t_format(self):
688688
)
689689

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

0 commit comments

Comments
 (0)