Skip to content

Normative: Take language subtag into account in locale hour cycle and calendar lookup - #1086

Merged
gibson042 merged 2 commits into
tc39:mainfrom
ptomato:1056-hourcyclesoflocale-language-subtag
Jul 22, 2026
Merged

Normative: Take language subtag into account in locale hour cycle and calendar lookup#1086
gibson042 merged 2 commits into
tc39:mainfrom
ptomato:1056-hourcyclesoflocale-language-subtag

Conversation

@ptomato

@ptomato ptomato commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Some of CLDR's hour cycle preference data is indexed by language and region, not just by region.

For example, Francophone Canada is listed as preferring a 24-hour clock while Anglophone Canada is listed as preferring a 12-hour clock. As of the current version of the spec text, it is not possible to return a value that takes these preferences into account, because only the region (Canada) is used for looking up the hour cycle preference.

This observably affects code such as

new Intl.Locale("fr-CA").getHourCycles()

which, after this change, will return an array where element 0 is "h23", instead of "h12".

Closes: #1056

@ptomato

ptomato commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Open question is whether we should rewrite the other preference lookup operations to work like this. As far as I can tell, hour cycles is the only data source where it matters. (Aside from <weekOfPreference> data, which we don't expose in JS.)

@gibson042 gibson042 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question is whether we should rewrite the other preference lookup operations to work like this. As far as I can tell, hour cycles is the only data source where it matters. (Aside from <weekOfPreference> data, which we don't expose in JS.)

It definitely makes sense for CalendarsOfLocale, which also already uses RegionPreference and is specifically covered by rgScope.xml, and probably is not appropriate for TimeZonesOfLocale.

I'd like to just completely defer to <rgScope> per UTS #35 Part 6 Supplemental, but that'll be a bigger effort.

Comment thread spec/locale.html Outdated
@gibson042 gibson042 added the s: discuss Status: TG2 must discuss to move forward label Jul 7, 2026
@ptomato
ptomato force-pushed the 1056-hourcyclesoflocale-language-subtag branch from 5c22c44 to 16b92c1 Compare July 8, 2026 00:15
@ptomato

ptomato commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

I've made the same change for CalendarsOfLocale, although there are not currently any language-region entries in CLDR's calendar preference data.

Note interactions with other open PRs:

ptomato added 2 commits July 14, 2026 16:36
Some of CLDR's hour cycle preference data is indexed by language and
region, not just by region.

For example, Francophone Canada is listed as preferring a 24-hour clock
while Anglophone Canada is listed as preferring a 12-hour clock. As of
the current version of the spec text, it is not possible to return a
value that takes these preferences into account, because only the
region (Canada) is used for looking up the hour cycle preference.

This observably affects code such as

    new Intl.Locale("fr-CA").getHourCycles()

which, after this change, will return an array where element 0 is "h23",
instead of "h12".

Closes: tc39#1056
@ptomato

ptomato commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Tests in tc39/test262#5091 (which V8 and JSC already pass)

@sffc sffc changed the title Normative: Take language subtag into account in locale hour cycle lookup Normative: Take language subtag into account in locale hour cycle and calendar lookup Jul 22, 2026
@gibson042
gibson042 merged commit 8a44678 into tc39:main Jul 22, 2026
2 checks passed
@ptomato
ptomato deleted the 1056-hourcyclesoflocale-language-subtag branch July 22, 2026 21:06
ptomato added a commit to ptomato/test262 that referenced this pull request Jul 23, 2026
This test is for the normative PR
tc39/ecma402#1086, where getHourCycles() and
getCalendars() are changing to use language-region data if available,
instead of just region-specific.

It is not possible to write a test for getCalendars() since currently
there are no known implementations where language-region-specific
calendar preferences exist.

LLM disclosure: I used a bot to search for suitable input locale
candidates. I also used the same bot for a first draft of the test
file, although I basically discarded the result.
ptomato added a commit to tc39/test262 that referenced this pull request Jul 23, 2026
This test is for the normative PR
tc39/ecma402#1086, where getHourCycles() and
getCalendars() are changing to use language-region data if available,
instead of just region-specific.

It is not possible to write a test for getCalendars() since currently
there are no known implementations where language-region-specific
calendar preferences exist.

LLM disclosure: I used a bot to search for suitable input locale
candidates. I also used the same bot for a first draft of the test
file, although I basically discarded the result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs consensus needs review s: discuss Status: TG2 must discuss to move forward

Projects

Status: Priority Issues

Development

Successfully merging this pull request may close these issues.

HourCyclesOfLocale: Add language subtag to lookup

3 participants