Skip to content

Cyclic year doesn't show up in resolvedOptions #816

Open
tc39/test262
#5155

Description

@sffc

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: ')'}

Activity

  1. added
    s: discussStatus: TG2 must discuss to move forward
    c: datetimeComponent: dates, times, timezones
    on Aug 1, 2023
  2. anba commented on Aug 7, 2023

    @anba
    Contributor

    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".)

  3. moved this to Other Issues in ECMA-402 Meeting Topicson Aug 22, 2024
  4. added this to the Next ECMAScript Release milestone on Sep 17, 2026
  5. added
    s: help wantedStatus: help wanted; needs proposal champion
    and removed
    s: discussStatus: TG2 must discuss to move forward
    on Sep 17, 2026
  6. sffc commented on Oct 15, 2026

    @sffc
    ContributorAuthor

    TG2 discussion: https://github.com/tc39/ecma402/blob/main/meetings/notes-2026-10-08.md#issue-816---cyclic-year-doesnt-show-up-in-resolvedoptions

    The spec seems correct, but the engines are not correct. Please add test262.

  7. jugglinmike commented on Oct 21, 2026

    @jugglinmike
    Contributor

    I've submitted tests for review here: tc39/test262#5155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: datetimeComponent: dates, times, timezonescalendars: help wantedStatus: help wanted; needs proposal champion

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions