Default partial date parsing to year 1970 - #15
Draft
viacheslav-augment wants to merge 2 commits into
Draft
Conversation
When a date format omits the year, Joda defaults the missing year to 2000. Set the parsers' default year to 1970 so partial dates use the epoch base, consistent with the 1970-01-01 base already used for round-ceil parsing in DateMathParser and with how partial dates are indexed.
Covers Joda.forPattern parsers defaulting the missing year to the 1970 epoch base rather than joda's default of 2000.
Author
|
👋 I've got this PR. I'll handle review feedback, CI failures, and merge conflicts, and ping you the moment it's ready for review. Drop a comment anytime. Marking it ready and picking reviewers are your call — I'll leave both alone. |
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.
Problem
When a date format omits the year, Joda defaults the missing year to 2000, so partial dates (e.g. a time-only or month/day value) parse into the wrong year.
Solution
Set the parsers built in
Joda.forPatterntowithDefaultYear(1970)so partial dates use the epoch base — consistent with the1970-01-01base already used for round-ceil parsing inDateMathParserand with how partial dates are indexed. Full dates are unaffected.Testing
Added a
DateMathParserTestscase asserting a year-lessMM-ddpattern parses01-01→ epoch0and06-15→1970-06-15.Pull Request opened by Augment Code | View session