Reject impossible timestamps with one strict parser - #59
Merged
Merged
Conversation
DateTime.tryParse rolls out-of-range fields into another instant, so 2026-02-30T10:00:00Z validated and counted as a usable verification. parseIsoDateTime checks each field before parsing, and both the spec rules and the metadata accessors use it.
This was referenced Sep 11, 2026
Merged
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.
Part of #57. It covers the impossible-value half. The missing-offset half changes what is valid, so it lands with the spec adoption in #56.
Problem.
DateTime.tryParserolls out-of-range fields over instead of rejecting them.2026-02-30T10:00:00Zbecomes 2 March, and2026-09-11T25:61:61Zbecomes the next day. The spec rules and the metadata accessors each parsed timestamps this way, so impossiblegenerated.atandverified[].atvalues raised no advisory, and an impossible verification counted as usable.Change.
parseIsoDateTimeinlib/src/iso_date.dartaccepts the ISO 8601 extended and basic forms, with optional fractional seconds and offset. It checks the month, the day (including leap years), the hour, minute and second, and the offset before it parses.okf/invalid-generatedandokf/invalid-verifieduse it, and so doOkfGeneration.atDateTime,OkfVerification.atDateTime/isUsableand the legacytimestampaccessor.Compatibility. Findings stay advisories, so no bundle that passes today fails. Bundles with impossible values now get the advisory they should always have had. A verification with an impossible
atis no longer usable.Checks.
dart format,dart analyze --fatal-infosanddart test(219 tests) pass locally. New tests are intest/iso_date_test.dart.There is no CHANGELOG entry: the first
## <version>section feeds release notes, so it will be added with the release.