temporal icon indicating copy to clipboard operation
temporal copied to clipboard

We should remap out-of-range eras

Open Manishearth opened this issue 5 months ago • 2 comments

From the spec:

In the Japanese calendar, when fields.[[Era]] is not unset and the date represented by fields is not within the bounds of that era, fields.[[Era]] should be updated to the appropriate containing era for that date (for example, because the transition from Heisei era [[EraYear]] 31 to Reiwa era [[EraYear]] 1 took place on May 1 of [[Year]] 2019, Heisei era [[EraYear]] 32 should be updated to Reiwa era [[EraYear]] 2, Reiwa era [[EraYear]] 1 [[Month]] 1 should be updated to Heisei era [[EraYear]] 31 [[Month]] 1, etc.).

Responsible for these test failures:

  'intl402/Temporal/PlainDate/from/remapping-era': [FAIL],
  'intl402/Temporal/PlainDate/prototype/with/cross-era-boundary': [FAIL],
  'staging/Intl402/Temporal/old/japanese-before-era': [FAIL],

Manishearth avatar Jul 24 '25 05:07 Manishearth

It occurred to me that to some extent we can just handle this by exclusively passing arithmetical year down to ICU4X.

The long term fix is https://github.com/unicode-org/icu4x/issues/6790 since that will also correctly handle month/day.

I tried making this fix but I hit test failures due to https://github.com/unicode-org/icu4x/pull/6794.

Manishearth avatar Aug 03 '25 06:08 Manishearth

From #442

Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, monthCode: "M01", day: 1, calendar: "japanese"}, {overflow: "constrain"})

And Shane's comment:

"reiwa 0" should be normalized to "heisei 29" or whatever. This applies to all eras in all calendars.

Manishearth avatar Aug 03 '25 15:08 Manishearth