Skip to content
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

Polyfill: Buddhist, Ethiopic-Amete-Alem, Indian, Islamic, and Persian calendar return non-undefind era #2899

Open
anba opened this issue Jun 19, 2024 · 3 comments
Labels
no-spec-text PR can be ignored by implementors non-prod-polyfill THIS POLYFILL IS NOT FOR PRODUCTION USE!

Comments

@anba
Copy link
Contributor

anba commented Jun 19, 2024

Temporal.PlainDate.from({calendar: "buddhist", year: 1000, month: 1, day: 1}).era

returns "be" instead of undefined. Same applies for calendars ethioaa, indian, islamic (and variants), and persian.

Calendars chinese, dangi, and hebrew correctly return undefined for the era.

From CalendarDateEra:

It performs implementation-defined processing to find the era for the date corresponding to date in the context of the calendar represented by calendar and returns a lowercase String value representing that era, or undefined for calendars that do not have eras.

@ptomato
Copy link
Collaborator

ptomato commented Jun 27, 2024

This should be deferred to experts in those calendars, but the current era info in the polyfill comes from Intl.DateTimeFormat:

> new Intl.DateTimeFormat('en', {calendar: 'buddhist'}).format(Date.now())
'6/27/2567 BE'

@anba
Copy link
Contributor Author

anba commented Jun 27, 2024

The era is possibly only displayed for English to disambiguate from the Gregorian calendar. When using locales which actually use the calendars, no era is displayed:

js> new Intl.DateTimeFormat("th", {calendar: "buddhist"}).format(Date.now())
"27/6/2567"
js> new Intl.DateTimeFormat("fa", {calendar: "persian", numberingSystem: "latn"}).format(Date.now())
"1403/4/7"
js> new Intl.DateTimeFormat("am", {calendar: "ethioaa"}).format(Date.now()) 
"20/10/7516"

@ptomato
Copy link
Collaborator

ptomato commented Jun 27, 2024

Oh. That explains it!

@ptomato ptomato added non-prod-polyfill THIS POLYFILL IS NOT FOR PRODUCTION USE! no-spec-text PR can be ignored by implementors labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-spec-text PR can be ignored by implementors non-prod-polyfill THIS POLYFILL IS NOT FOR PRODUCTION USE!
Projects
None yet
Development

No branches or pull requests

2 participants