Registry Mirror
Skip to content

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses the dominant clusters of the intl402/Temporal parity tail (#5580). Perry's PlainDateTime / ZonedDateTime property-bag reader (read_iso_fields_alpha, read_zoned_bag_alpha) and Temporal.PlainMonthDay.prototype.toPlainDate's year-field reader never read the era/eraYear keys.

For a calendar that uses eras, an { era, eraYear, monthCode, day } bag therefore reached temporal_rs/ICU4X with no resolvable year and threw TypeError: Insufficient fields. — the single biggest reason in the #5580 table (84) — and a with({ era, eraYear }) likewise dropped the era keys (the fields cannot be empty / mutually-exclusive-fields-* cluster, 24).

What changed

  • era/eraYear are now read in their alphabetical position (right after day, before hour) for era-using calendars in the PlainDateTime/ZonedDateTime from + with paths and in PlainMonthDay.toPlainDate's YEAR field group. Era-relative dates resolve, and a non-finite eraYear rejects with the spec RangeError (the *-infinity-throws-rangeerror cases).
  • New calendar_has_no_eras keeps the era-less calendars (iso8601, chinese, dangi) skipping those keys, so from({ era, eraYear, year, … }) ignores them and a with({ era, eraYear }) bag stays empty → the EmptyFieldsIsInvalid TypeError rather than an Unknown era RangeError.
  • ISO order-of-operations is unchanged — an ISO bag still observes no era/eraYear gets (verified against built-ins/Temporal/{PlainDateTime,…}/from/order-of-operations.js).

Validation

Self-validated test262 sweep, intl402/Temporal, pinned 4249661388e5d3f92a85186213da140a6481490f:

pass fail parity
before 1786 243 88.0%
after 1923 106 94.8%

137 fixed, 0 regressions. The remaining 106 are the Intl toLocaleString / DateTimeFormat formatting clusters (default-locale, [object Object], dateStyle long-month, etc.), which need CLDR/ICU formatting data and are out of scope here.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved Temporal field handling so calendar-specific values are read more reliably.
    • with and toPlainDate now respect the object’s calendar when deriving date fields.
    • ZonedDateTime.with now preserves calendar context when applying field updates.
    • Era and era-year values are handled correctly for calendars that don’t use eras, improving consistency across calendar types.

…nDateTime/ZonedDateTime/PlainMonthDay field bags

The PlainDateTime / ZonedDateTime property-bag reader (`read_iso_fields_alpha`,
`read_zoned_bag_alpha`) and `PlainMonthDay.prototype.toPlainDate`'s year-field
reader never read the `era`/`eraYear` keys. For a calendar that uses eras
(gregory, japanese, roc, buddhist, coptic, ethiopic/ethioaa, the islamic
family, hebrew, indian, persian) an `{ era, eraYear, monthCode, day }` bag
therefore reached temporal_rs/ICU4X with no resolvable year and threw
`Insufficient fields` (the dominant intl402/Temporal failure cluster), and a
`with({ era, eraYear })` likewise dropped the era keys. They are now read in
their alphabetical position (right after `day`, before `hour`) for era-using
calendars only, so era-relative dates resolve and a non-finite `eraYear`
rejects with the spec `RangeError`.

Era-less calendars — `iso8601`, `chinese`, `dangi` — still skip the keys
(new `calendar_has_no_eras`), so `from({ era, eraYear, year, … })` ignores them
and a `with({ era, eraYear })` bag stays empty → the `EmptyFieldsIsInvalid`
TypeError rather than an `Unknown era` RangeError. ISO order-of-operations is
unchanged (an ISO bag still observes no era/eraYear gets).

intl402/Temporal self-validated test262 sweep (pinned 4249661): 1786→1923 pass
(243→106 fail, 88.0%→94.8%), 137 fixed, 0 regressions. Remaining failures are
the Intl `toLocaleString`/DateTimeFormat formatting clusters (need CLDR data),
out of scope here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 49138167-f091-4cb0-8790-0be6afbe73e0

📥 Commits

Reviewing files that changed from the base of the PR and between ef9cee1 and 674e708.

📒 Files selected for processing (4)
  • crates/perry-runtime/src/temporal/options.rs
  • crates/perry-runtime/src/temporal/plain_date_time.rs
  • crates/perry-runtime/src/temporal/plain_month_day.rs
  • crates/perry-runtime/src/temporal/zoned_date_time.rs

📝 Walkthrough

Walkthrough

Adds a calendar_has_no_eras predicate and refactors read_era_fields to skip era/eraYear for calendars without eras (e.g. iso8601, chinese, dangi). Propagates a resolved Calendar parameter through read_iso_fields_alpha, read_zoned_bag_alpha, to_plain_date_year_field, and the four exported field helpers, and wires the calendar through all call sites in options.rs and the with/toPlainDate methods of PlainDateTime, ZonedDateTime, and PlainMonthDay.

Changes

Calendar-aware era/eraYear marshalling

Layer / File(s) Summary
Era-support predicate and read_era_fields
crates/perry-runtime/src/temporal/options.rs
Introduces calendar_has_no_eras and updates read_era_fields to gate era/eraYear reading on calendar support instead of an ISO-only check.
Internal field-reader helpers
crates/perry-runtime/src/temporal/options.rs
Updates to_plain_date_year_field, read_iso_fields_alpha, and read_zoned_bag_alpha to accept calendar: &Calendar, invoke read_era_fields, and assign cf.era / cf.era_year in alphabetical spec order.
Exported function signatures and all call-site wiring
crates/perry-runtime/src/temporal/options.rs, crates/perry-runtime/src/temporal/plain_date_time.rs, crates/perry-runtime/src/temporal/plain_month_day.rs, crates/perry-runtime/src/temporal/zoned_date_time.rs
Adds calendar: &Calendar to datetime_fields, with_datetime_fields, zoned_fields, and to_plain_date_year_field, and passes the instance's calendar at every call site including plain_date_time_from_bag, relative_to, zoned_partial, and the with/toPlainDate method branches.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop, hop — no eras for ISO today,
The calendar whispers which fields are in play.
era and eraYear now know their place,
Threaded with calendar through every chase.
The spec-order march goes alpha by alpha — hooray! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main Temporal era/eraYear fix.
Description check ✅ Passed The description covers the summary, changes, related issue, and validation, with only optional template sections omitted.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-fix-5580-temporal-intl

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug merged commit 49a67a9 into main Jun 24, 2026
14 checks passed
@proggeramlug
proggeramlug deleted the worktree-fix-5580-temporal-intl branch June 24, 2026 13:13
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.

1 participant