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:
https://github.com/django/django/blob/0e94f292cda632153f2b3d9a9037eb0141ae9c2e/django/utils/formats.py#L266-L273
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
CC @blhsing @martinvuyk
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs