Repository navigation
Reject days that do not exist in the date and date-time formats - #228
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
The date and date-time regexps allowed days 29 to 31 in every month, so 2021-02-29, 2020-02-30 and 2021-04-31 were accepted. The day must now exist in its month, and 29 February needs a leap year (divisible by 4, and by 400 for century years). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
dateanddate-timeformats checked each part's range but not the combination, so2021-02-29,2020-02-30and2021-04-31were accepted: day29to31was allowed in every month.This adds one calendar-aware
DATE_REGEXshared by both formats: days 1 to 31 for January, March, May, July, August, October and December, 1 to 30 for April, June, September and November, 1 to 28 for February, and02-29only in a leap year (a year divisible by 4, and by 400 when it is a century year). It stays a regexp, like the other formats, so there is no new import and the generated code is the same shape. The named groupsyear,monthanddayof thedateregexp were not used anywhere and are gone.Tests:
test_dateandtest_datetimeintests/test_format.pyget cases for non-existent days (including1900-02-29and2100-02-29) and for valid edges (2020-02-29,2000-02-29,2400-02-29,2021-04-30). The new rejection cases fail on master and pass now. The suite gives 636 passed and 4 skipped; the 12 errors are the benchmark tests, which need a fixture that was not installed here.This change was made with Claude Code.
🤖 Generated with Claude Code