Fix month/year range parsing overflow on month-end dates#539
Merged
Conversation
Merged
arran4
added a commit
that referenced
this pull request
Feb 20, 2026
…ests-and-fix-issues Auto-format for #539
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.
Motivation
TimeParser.parseRangeproduced incorrect start dates for month/year ranges when the current day did not exist in the target month (e.g., subtracting one month from Mar 31), causing overflows instead of clamping to the last valid day.Description
_subtractMonths,_subtractYears, and_daysInMonthtolib/utils/time_parser.dartto centralize correct date arithmetic and clamp day-of-month to the last valid day of the target month.DateTimearithmetic in both the duration-based (last N month/year) and phrase-based (last month,last year) branches ofparseRangeto use the new helpers and preserve time components.should clamp day for month and year range phrasesintest/time_parser_test.dartthat verifies correct clamping forlast 1 monthandlast 1 yearwith preserved time-of-day.Testing
dart format .but it failed in this environment becausedartis not installed, so formatting could not be verified here.flutter analyzebut it failed in this environment becauseflutteris not installed, so static analysis could not be run here.dart test .but it failed in this environment becausedartis not installed, so the new unit test was not executed here; CI should run the test suite and is expected to pass with the changes.Codex Task