Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling 29 Feb in en_US Passport provider #1872

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Jun 2, 2023

What does this change

Fixes ValueError when the passport issue date is 29 Feb, and therefore the expiration date would fall on 29 Feb of a non-leap year.

What was wrong

The expiration code was replacing the year within the date without accounting for the possibility that said day may not exist in the expiration year.

How this fixes it

It adjusts the date to 28 Feb.

Fixes #1870

I've also noticed that the last lines of every if case is the same, so I've moved them below the if to reduce duplication.

Fix handling the issue date of 29 Feb (of a leap year).  Since
the passports expire in 5 or 10 years, the expiration year will not be
a leap year, and therefore the date needs to be adjusted to 28 Feb.

Fixes joke2k#1870
Copy link
Collaborator

@fcurella fcurella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fcurella fcurella merged commit ee3ed38 into joke2k:master Jun 2, 2023
@mgorny
Copy link
Contributor Author

mgorny commented Jun 3, 2023

Thanks!

@mgorny mgorny deleted the passport-dates branch June 3, 2023 04:36
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.

tests/test_passport.py::TestEnUS::testDates failure: ValueError: day is out of range for month
2 participants