Closed
Description
Bug report
Bug description:
#120713 changed the way %y
and %Y
format works with strftime()
to pad "short" years with leading zeros. However, the %F
and %C
formats were left alone, creating inconsistency:
>>> from datetime import date
>>> date(909, 9, 9).strftime("%Y")
'0909'
>>> date(909, 9, 9).strftime("%y")
'09'
>>> date(909, 9, 9).strftime("%C")
'9'
>>> date(909, 9, 9).strftime("%F")
'909-09-09'
While I don't have a strong opinion about %C
, the change to %Y
now means that %Y-%m-%d
no longer matches %F
.
Notably, this change broke the logic in Django that assumed that if %Y
returns a zero-padded year number, no padding needs to be done for all formats:
I will report a bug there as well, but I think it would be beneficial to preserve consistency here.
Django bug: https://code.djangoproject.com/ticket/35630
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done
Status
Done