Repository navigation
Conversation
When a format had a day but no year or month, the missing values were cast to 0, so checkdate() always failed and valid input such as "15/03" for "d/m" was rejected. Missing values now default to 1, while explicit zeros like year 0000 are still rejected.
Cover "d/m", "m/d", "d" and "F j" with valid input, plus an impossible
date ("31/02" for "d/m") that must still be rejected.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1883 +/- ##
=========================================
Coverage 97.18% 97.18%
- Complexity 1096 1098 +2
=========================================
Files 198 198
Lines 2555 2558 +3
=========================================
+ Hits 2483 2486 +3
Misses 72 72 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Datenow accepts valid input for formats that have a day but no year or month, such asd/m.Motivation
Dateaccepts formats liked/m,m/d,dandF j, but valid input for them is always rejected.When a field is missing from the format,
date_parse_from_format()returnsfalsefor it.isDateInformation()cast these values to0, socheckdate()always failed.Formats without a day already defaulted missing values to
1, so the two branches behaved differently.What I have done
In
CanValidateDateTime::isDateInformation(), a missing month or year now defaults to1when the format has a day.Only
falseis replaced, so explicit zeros such as year0000or month00are still rejected as before.Impossible dates are still rejected by the existing round trip check.
Test plans
Added the following cases to
DateTest.d/mwith15/03,m/dwith03/15,dwith15andF jwithMarch 5d/mwith31/02Test Results