Skip to content

fix: read a DateTimeOffset offset only in the ISO forms - #244

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/datetimeoffset-offset-forms
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/datetimeoffset-offset-forms

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #234

Problem

DateTimeOffsetRange and DateTimeOffsetSet read +0530, -0530 and +5:30 through .NET's zzz format. The docs say otherwise: docs/serialization.md gives the offset as Z, ±HH, ±HH:mm or ±HH:mm:ss, and docs/migration.md says "+0530 and +5:30 are rejected". The sibling types DateTimeRange, InstantRange and LocalDateTimeRange reject 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.ParseDateTimeOffset now requires a trailing Z or an ISO offset before the BCL parse, using OffsetLength, the same rule DateTime uses. That covers every entry point: literals, sets, JSON, TypeConverter, configuration and the EF bridge. The rejection message is unchanged.
  • Measured before the change, through ParseValue: DateTimeOffset accepted +0530, -0530 and +5:30, and already rejected +1430 and +1530. DateTime rejected all five.
  • CHANGELOG 10.0.0 → Breaking: one entry. docs/migration.md v9.x: one bullet, linking the existing strict-ISO section.

Tests

  • TemporalLiteralGrammarTests.DateTimeOffset_Rejects: new rows +0530, -0530, +5:30, +1430, +1530 and T09:30+0530.
  • TemporalLiteralStrictnessContractTests: +0530 and +5:30 added for DateTime, DateTimeOffset, LocalDateTime and Instant. This sweep runs every entry point of every discovered type, wrappers included.
  • LiteralCorpusProbeTests (timestamptz): the five spellings as non-ISO temporal. That family is a documented rejection.
  • Pre-check removed: four reject rows fail, and so does the strictness sweep ("DateTimeOffsetRange [… +0530 …]: Parse accepted it"). +1430 and +1530 pass 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.
  • Core 1351, NodaTime 232, conventions 395, EF unit 284, integration 256 (PostgreSQL 16), ASP.NET Core 92: all passed.

🤖 Generated with Claude Code

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]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working breaking Changes an answer or a signature — needs a major area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference labels Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 0c9c3f3 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/datetimeoffset-offset-forms branch October 18, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting breaking Changes an answer or a signature — needs a major bug Something isn't working package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateTimeOffset bounds and elements accept +0530 and +5:30, which the docs and the sibling types refuse

1 participant