-
Notifications
You must be signed in to change notification settings - Fork 172
Description
https://tc39.es/proposal-temporal/#sec-temporal-nonisoresolvefields
This has the following text:
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.).
However, in CalendarYearMonthFromFields
, it says:
- Let firstDayIndex be the 1-based index of the first day of the month described by fields (i.e., 1 unless the month's first day is skipped by this calendar.)
This isn't quite clear on what "the first day of the month described by fields" is. January Heisei 1and January 64 Showa are the same month.
In the polyfill, currently, Temporal.PlainYearMonth.from({calendar: "japanese", era: "heisei", eraYear: 1, month: 1}).era
produces "showa"
, because it constrains down to a reference day of Janaury 1, which is in Showa, even though January 8 is in Heisei.
Personally I think it makes sense for (Heisei 1, January) and (Showa 64, January) to be considered distinct YearMonths, but perhaps we wish to talk about the abstract month here and in that case the current behavior makes sense. Either way, this should probably be explicitly considered and noted.
As an aside, I'm noticing that CalendarResolveFields handles most of the "figure out the rest of the fields" behavior, but reference year / reference day calculation is in callers. It might be cleaner to have it all in one place under CalendarResolveFields/NonISOResolveFields.
cc @sffc