ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Make list of supported calendars

Open sffc opened this issue 5 years ago • 4 comments

In Section 6 of the spec, we have well-defined rules for supported locales, currencies, and time zones, and Unified NumberFormat is adding a specific list of supported units.

I think we need to also add a list of supported calendars. We are increasingly using calendars throughout Intl APIs, and we will also be using them in Temporal.

@pipobscure

sffc avatar Dec 11 '19 00:12 sffc

I think that's a good idea.

pipobscure avatar Dec 11 '19 12:12 pipobscure

Just for background, why supported calendars when we don't have supported locales (and we're pretty set on not adding that)?

littledan avatar Dec 11 '19 15:12 littledan

why supported calendars when we don't have supported locales

Good question.

Locales are used only for output. Programmers should generally not use the result of .format operations for any other purpose. However, with calendars being supported in Temporal, which provides more sophisticated operations, I think programmers reasonably have a higher expectation for knowing which ones they can safely use on their website.

For example, if a website targeting Chinese users wanted to do date math specifically in the traditional Chinese calendar, they would have to test whether their date math works in all browsers.

An alternative could be for Temporal to have its own set of supported calendars, but let Intl.DateTimeFormat implement its own. However, I think this is not a good idea, because I think programmers should have the expectation that the following command always works without throwing a RangeError:

Temporal.now.date().withCalendar(Intl.defaultCalendar)

We can brush that issue under the rug by vague spec language that says that any calendar supported for display in Intl.DateTimeFormat must also be supported for calculations by Temporal. But then we get back to the first issue of programmers not knowing which explicit calendars are supported.

sffc avatar Dec 11 '19 17:12 sffc

Discussion from ECMA-402 meeting: https://github.com/tc39/ecma402/blob/master/meetings/notes-2020-01-09.md#issue-make-list-of-supported-calendars. Key points:

  • DE: We have required numbering systems. It does seem like a fatal error if someone counts on a particular locale to be present but it is not.
  • LHO: From a polyfill perspective, this would be difficult, to have a list of mandatory calendars, because there is more to do.

We therefore did not reach a conclusion. Therefore, I want to propose that we simply add the following requirement: "any calendar that is supported for formatting must also be supported for Temporal". This can be part of the Intl Temporal effort.

sffc avatar Feb 26 '20 06:02 sffc

I believe this is fixed:

https://tc39.es/proposal-temporal/#sec-calendar-types says that Temporal should support exactly the same set of built-in calendars as ECMA-402

Intl Enumeration API gives an iterator over those calendar types.

sffc avatar May 02 '24 23:05 sffc