Skip to content

Behavior of YearMonth around Japanese era boundaries #3150

@Manishearth

Description

@Manishearth

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:

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions