tc39 / proposal-intl-era-monthcode

To specify necessary details about era, eraYear and monthCode usage with Temporal in internationalization setting (for calendars other than "iso8601").
https://tc39.github.io/proposal-intl-era-monthcode
MIT License
3 stars 3 forks source link

Calendars with and without a week numbering system #15

Open ptomato opened 10 months ago

ptomato commented 10 months ago

This discussion was prompted by tc39/proposal-temporal#2744.

The ISO 8601 calendar has an official, well-specified week numbering system. The Gregorian calendar uses the same week numbering system as ISO 8601, by convention in many locales whose preferred calendar is gregory.

Whether other calendars have week numbering systems, I don't have the expertise to know. I think the question of whether a calendar has a week-numbering system, and how it works if so, is something that could be moved into the scope of this proposal, to prevent divergence between implementations.

ICU has generalized week-numbering code: https://github.com/unicode-org/icu/blob/ab72ab1d4a3c3f9beeb7d92b0c7817ca93dfdb04/icu4c/source/i18n/calendar.cpp#L1606 However, I don't know which calendars this is used for in practice. CLDR-JSON has week formats in the Gregorian calendar: https://github.com/unicode-org/cldr-json/blob/858baad63c1d51e1d576ef99dccc229d92cedda4/cldr-json/cldr-dates-full/main/en/ca-gregorian.json#L396 But not in the Japanese calendar, which does have the same years and weeks as Gregorian (just not the same year numbers): https://github.com/unicode-org/cldr-json/blob/858baad63c1d51e1d576ef99dccc229d92cedda4/cldr-json/cldr-cal-japanese-full/main/en/ca-japanese.json#L1053

Concretely, this suggestion would mean including CalendarDateWeekOfYear in the scope of this proposal. (Note, we are planning to present a normative PR in the next TC39 plenary to allow calendars without a week numbering system to return { [[Year]]: undefined, [[Week]]: undefined } from this operation.)

Manishearth commented 10 months ago

Note, we are planning to present a https://github.com/tc39/proposal-temporal/pull/2756 in the next TC39 plenary to allow calendars without a week numbering system to return { [[Year]]: undefined, [[Week]]: undefined } from this operation

I think this would be quite good to do. The full week numbering algorithm is quite ... specific and it's unclear if it's generalizeable to calendars that do not use it.

From an implementor point of view (ICU4X) calculating the information needed for the ISO 8601 algorithm can be expensive for non-gregorian calendars (since you need the number of days in the previous year, information not needed otherwise) and it's almost always wasted effort.