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

Cyclic year doesn't show up in resolvedOptions #816

Open
sffc opened this issue Aug 1, 2023 · 1 comment
Open

Cyclic year doesn't show up in resolvedOptions #816

sffc opened this issue Aug 1, 2023 · 1 comment
Labels
c: datetime Component: dates, times, timezones calendar s: discuss Status: TG2 must discuss to move forward

Comments

@sffc
Copy link
Contributor

sffc commented Aug 1, 2023

In CreateDateTimeFormat, it says:

  1. For each row in Table 7, except the header row, in table order, do
    a. Let prop be the name given in the Property column of the row.
    b. If bestFormat has a field [[<prop>]], then
    i. Let p be bestFormat.[[<prop>]].
    ii. Set dateTimeFormat's internal slot whose name is the Internal Slot column of the row to p.

In Table 7, the year is stated as being either "numeric" or "2-digit". However, this is clearly not reflected in the Chinese calendar resolvedOptions, which uses r and U (related Gregorian and cycle year name):

new Intl.DateTimeFormat("en", { calendar: "chinese", year: "numeric" }).format(new Date())
// '2023(gui-mao)'
new Intl.DateTimeFormat("en", { calendar: "chinese", year: "numeric" }).resolvedOptions()
// {locale: 'en', calendar: 'chinese', numberingSystem: 'latn', timeZone: 'America/Los_Angeles'}

It works fine in formatToParts:

0: {type: 'relatedYear', value: '2023'}
1: {type: 'literal', value: '('}
2: {type: 'yearName', value: 'gui-mao'}
3: {type: 'literal', value: ')'}
@sffc sffc added s: discuss Status: TG2 must discuss to move forward c: datetime Component: dates, times, timezones calendar labels Aug 1, 2023
@sffc sffc added this to Other Issues in ECMA-402 Meeting Topics Aug 1, 2023
@anba
Copy link
Contributor

anba commented Aug 7, 2023

Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string when the format record has a [[year]] field. And if a [[year]] field is present, CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions should then return the value of the [[Year]] internal slot.

IOW this seems to be spec'ed correctly, it's just that engines don't implement this correctly.

As long as the pattern string can't contain both "{year}" and "{relatedYear}", engines simply have to map the 'r' and 'U' Date Field Symbols to year: "numeric". (The related-year can only be "numeric", never "2-digit".)

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 5, 2023
…solved components. r=dminor

Map both "r" (related Gregorian year) and "U" (cyclic year name) to a resolved numeric year.

From <tc39/ecma402#816 (comment)>:
> Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string
> when the format record has a [[year]] field. And if a [[year]] field is present,
> CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the
> format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions
> should then return the value of the [[Year]] internal slot.

Fixes <tc39/ecma402#816>.

Differential Revision: https://phabricator.services.mozilla.com/D189542
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 6, 2023
…solved components. r=dminor

Map both "r" (related Gregorian year) and "U" (cyclic year name) to a resolved numeric year.

From <tc39/ecma402#816 (comment)>:
> Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string
> when the format record has a [[year]] field. And if a [[year]] field is present,
> CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the
> format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions
> should then return the value of the [[Year]] internal slot.

Fixes <tc39/ecma402#816>.

Differential Revision: https://phabricator.services.mozilla.com/D189542
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 8, 2023
…solved components. r=dminor

Map both "r" (related Gregorian year) and "U" (cyclic year name) to a resolved numeric year.

From <tc39/ecma402#816 (comment)>:
> Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string
> when the format record has a [[year]] field. And if a [[year]] field is present,
> CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the
> format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions
> should then return the value of the [[Year]] internal slot.

Fixes <tc39/ecma402#816>.

Differential Revision: https://phabricator.services.mozilla.com/D189542

UltraBlame original commit: 54af7a41c821b47edcc55468310ba7c3e7a6573d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 8, 2023
…solved components. r=dminor

Map both "r" (related Gregorian year) and "U" (cyclic year name) to a resolved numeric year.

From <tc39/ecma402#816 (comment)>:
> Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string
> when the format record has a [[year]] field. And if a [[year]] field is present,
> CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the
> format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions
> should then return the value of the [[Year]] internal slot.

Fixes <tc39/ecma402#816>.

Differential Revision: https://phabricator.services.mozilla.com/D189542

UltraBlame original commit: 54af7a41c821b47edcc55468310ba7c3e7a6573d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 8, 2023
…solved components. r=dminor

Map both "r" (related Gregorian year) and "U" (cyclic year name) to a resolved numeric year.

From <tc39/ecma402#816 (comment)>:
> Per 11.2.3 Internal slots, "{relatedYear}" can only appear in a pattern string
> when the format record has a [[year]] field. And if a [[year]] field is present,
> CreateDateTimeFormat will set the Intl.DateTimeFormat's [[Year]] field to the
> format records [[year]] value. Intl.DateTimeFormat.prototype.resolvedOptions
> should then return the value of the [[Year]] internal slot.

Fixes <tc39/ecma402#816>.

Differential Revision: https://phabricator.services.mozilla.com/D189542

UltraBlame original commit: 54af7a41c821b47edcc55468310ba7c3e7a6573d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: datetime Component: dates, times, timezones calendar s: discuss Status: TG2 must discuss to move forward
Projects
Development

No branches or pull requests

2 participants