Repository navigation
Fix parsing of the Y year token in from_format() - #1054
vera-rubin wants to merge 1 commit into
Conversation
Wkhanex
left a comment
There was a problem hiding this comment.
I checked e77a6d7 with Python 3.12 in pure-Python mode. In addition to the 62 passing tests/datetime/test_from_format.py tests, I compared from_format(..., 'Y-MM-DD') against datetime for January 2, February 28 and December 31 of every year 1–9999 (29,997 comparisons). Those passed, including unpadded years such as 68 and 69 remaining literal years rather than receiving the YY pivot. I also checked that the existing YY pivot stays at 2068/1969 and that year 0, year 10000 and non-leap February 29 are rejected. This gives the one-entry token-map fix some coverage beyond the single leap-year example. I have not run the complete suite or the native extension backend.
Review and local validation prepared with OpenAI Codex assistance.
We get
KeyError: 'Y'when parsing2024-02-29withY-MM-DD, even though the documented year tokens includeY. This should return2024-02-29T00:00:00+00:00.The change adds integer conversion for
YalongsideYYYYandYY. We added a regression case and ran the full test suite with the Release extension and withPENDULUM_EXTENSIONS=0.Tested: Pendulum 3.3.0, master at
e06dacedc4cdea90fa1286b3965d180ab94cf251.Pull Request Check List
Y.— ChipLab