Repository navigation
fix: read a DateTimeOffset offset only in the ISO forms - #244
Merged
Merged
Conversation
DateTimeOffsetRange and DateTimeOffsetSet read +0530, -0530 and +5:30 through .NET's zzz format, although docs/serialization.md and docs/migration.md give the offset as Z, ±HH, ±HH:mm or ±HH:mm:ss, and DateTimeRange, InstantRange and LocalDateTimeRange refuse all three. PostgreSQL reads them, and the instant agreed, so no value was wrong. IsoTemporal.ParseDateTimeOffset now requires a trailing Z or an ISO offset (OffsetLength, the DateTime rule) before the BCL parse, on every entry point. A tightening, in the major's Breaking list. TemporalLiteralGrammarTests.DateTimeOffset_Rejects gains +0530, -0530, +5:30, +1430, +1530 and T09:30+0530; TemporalLiteralStrictnessContractTests gains +0530 and +5:30 for DateTime, DateTimeOffset, LocalDateTime and Instant through every entry point; the timestamptz corpus counts them as documented refusals. With the pre-check removed, four reject rows and the strictness sweep fail (+1430 and +1530 were refused already). Closes #234 Found-By: CA Defect-Class: LIT Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md
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.
Closes #234
Problem
DateTimeOffsetRangeandDateTimeOffsetSetread+0530,-0530and+5:30through .NET'szzzformat. The docs say otherwise:docs/serialization.mdgives the offset asZ,±HH,±HH:mmor±HH:mm:ss, anddocs/migration.mdsays "+0530and+5:30are rejected". The sibling typesDateTimeRange,InstantRangeandLocalDateTimeRangereject all three. PostgreSQL reads them and the instant matched, so no value was wrong, but the grammar disagreed with its documentation and its siblings.Change
IsoTemporal.ParseDateTimeOffsetnow requires a trailingZor an ISO offset before the BCL parse, usingOffsetLength, the same ruleDateTimeuses. That covers every entry point: literals, sets, JSON, TypeConverter, configuration and the EF bridge. The rejection message is unchanged.ParseValue:DateTimeOffsetaccepted+0530,-0530and+5:30, and already rejected+1430and+1530.DateTimerejected all five.docs/migration.mdv9.x: one bullet, linking the existing strict-ISO section.Tests
TemporalLiteralGrammarTests.DateTimeOffset_Rejects: new rows+0530,-0530,+5:30,+1430,+1530andT09:30+0530.TemporalLiteralStrictnessContractTests:+0530and+5:30added forDateTime,DateTimeOffset,LocalDateTimeandInstant. This sweep runs every entry point of every discovered type, wrappers included.LiteralCorpusProbeTests(timestamptz): the five spellings asnon-ISO temporal. That family is a documented rejection.+1430and+1530pass either way. The corpus rows don't fail on revert, because the probe still compares an accepted documented row by value and the instant matched; the strictness sweep is the guard here.🤖 Generated with Claude Code