-
Notifications
You must be signed in to change notification settings - Fork 111
Normative: Don't add default formatting to lone era #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Does this require any changes in https://tc39.es/ecma402/#sec-intl.datetimeformat-internal-slots? Right now neither When given the request
There's a removal penalty because |
I assumed no, because we also permit |
Yes, this is the important difference. Standalone |
Conclusion in the TG2 meeting today was:
|
Previously, if `era` was given by itself in the formatting options, the default formatting for the other date/time components would be added. This is inconsistent with what we do for `dayPeriod` where a lone `dayPeriod` produces formats such as "in the afternoon". The use case of obtaining the localized era name has also been mentioned several times. This change makes a lone `era` be passed to the format matcher algorithm without added date/time components, and requires implementations to have at least a year-month-day-era and year-month-era format available (which looks to be widely available across languages in CLDR.) See: tc39#461
28755d0
to
33a7366
Compare
I've updated this to modify only |
Although I would love to see this, I propose that we close this PR given that the following code has worked since Intl 1.0 and seems like a reasonable thing to write: new Intl.DateTimeFormat("en", { era: "long" }).format(new Date())
// '6/9/2025 Anno Domini' I think we should consider a different shape instead of redefining the current shape. |
Era was an option in Intl 1.0: https://402.ecma-international.org/1.0/index.html#sec-12.1.1.1 But even at that time, it was not not included in the list in question. Same applies to timeZoneName. |
As in #958 (comment), I'm seeking agreement on the following proposed conclusion:
|
I am pretty sure we didn't make a deliberate decision around the era: long that would produce the stated result. The only discussion relevant to dates was with Microsoft, which at the time couldn't support more than 5 specific skeletons. Thus the spec was left open for "implementer discretion on whether more than 5 skeletons are provided". |
TG2 agreed to the above conclusion. |
Previously, if
era
was given by itself in the formatting options, the default formatting for the other date/time components would be added. This is inconsistent with what we do fordayPeriod
where a lonedayPeriod
produces formats such as "in the afternoon".The use case of obtaining the localized era name has also been mentioned several times.
This change makes a lone
era
be passed to the format matcher algorithm without added date/time components, and requires implementations to have at least a year-month-day-era and year-month-era format available (which looks to be widely available across languages in CLDR.)See: #461