Skip to content

Fix parsing of the Y year token in from_format() - #1054

Open
vera-rubin wants to merge 1 commit into
python-pendulum:masterfrom
vera-rubin:fix/parse-year-token
Open

vera-rubin wants to merge 1 commit into
python-pendulum:masterfrom
vera-rubin:fix/parse-year-token

Conversation

@vera-rubin

Copy link
Copy Markdown

We get KeyError: 'Y' when parsing 2024-02-29 with Y-MM-DD, even though the documented year tokens include Y. This should return 2024-02-29T00:00:00+00:00.

import pendulum
print(pendulum.from_format("2024-02-29", "Y-MM-DD").isoformat())

The change adds integer conversion for Y alongside YYYY and YY. We added a regression case and ran the full test suite with the Release extension and with PENDULUM_EXTENSIONS=0.

Tested: Pendulum 3.3.0, master at e06dacedc4cdea90fa1286b3965d180ab94cf251.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code. The existing documentation already lists Y.

— ChipLab

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant