Skip to content

Serialize years above 9999 without chrono's leading '+'#157

Open
ajbufort wants to merge 1 commit into
Paligo:mainfrom
ajbufort:canonical-year-serialization
Open

Serialize years above 9999 without chrono's leading '+'#157
ajbufort wants to merge 1 commit into
Paligo:mainfrom
ajbufort:canonical-year-serialization

Conversation

@ajbufort

Copy link
Copy Markdown

Fixes #153.

string(xs:dateTime("10000-01-01T00:00:00Z")) produced "+10000-01-01T00:00:00Z" - chrono's %Y switches to a signed, ISO-8601-expanded representation for years above 9999, which is not valid XSD lexical form. The engine's own cast rejected its own output: xs:dateTime(string(xs:dateTime("10000-01-01T00:00:00Z"))) raised FORG0001.

The fix writes the year manually in canonical_date_time, canonical_date_time_stamp, and canonical_date via a small push_canonical_year helper, mirroring what canonical_g_year/canonical_g_year_month already did (those were unaffected). Negative years and year 0000 keep their existing (already-canonical) forms, pinned by tests.

Testing

  • New xee-xpath/tests/canonical_years.rs: the three affected types serialize five-digit years without +, the round trip through the engine's own cast now succeeds, and the already-correct forms (negative years, year 0000, xs:gYear) are pinned
  • Full battery clean: cargo fmt, clippy --all-targets --all-features -- -D warnings, workspace cargo test, and both conformance suites with no regressions (XPath verified in release and debug mode, as CI runs it)

Generated with Claude Code

string(xs:dateTime("10000-01-01T00:00:00Z")) produced
"+10000-01-01T00:00:00Z": chrono's %Y switches to a signed
representation for years above 9999, which is not part of XSD's
lexical space. The engine's own cast rejected its own output, so
xs:dateTime(string(xs:dateTime("10000-01-01T00:00:00Z"))) raised
FORG0001.

Write the year manually in canonical_date_time,
canonical_date_time_stamp and canonical_date through a
push_canonical_year helper, mirroring what canonical_g_year and
canonical_g_year_month already did. Negative years and year 0000 keep
their existing, already-canonical forms, pinned by tests along with
the round trip through the engine's own cast.

Fixes Paligo#153

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Years above 9999 serialize with a leading '+' that the engine's own casts reject

1 participant