Backport #4163 to 4.x: Intl.Locale getWeekInfo picks its region through RegionPreference - #4168
Merged
lahma merged 1 commit intoSep 24, 2026
Conversation
…region through RegionPreference Backport of PR sebastienros#4163 (commit ad44090) from main. getWeekInfo read CLDR week data for the tag's literal region subtag only, so a tag without one fell to 001 and the -u-rg- and -u-sd- keywords were ignored: "en" answered Monday and "en-US-u-rg-gbzzzz" Sunday. It now picks the region the way ECMA-402 RegionPreference does: a -u-rg- override CLDR has week data for, then the region subtag, then a -u-sd- subdivision's region, then the region Add Likely Subtags supplies, then 001. Both firstDay and weekend are read for that region; a -u-fw- keyword still wins for firstDay. Observable change, both now what the specification and every browser answer: - new Intl.Locale('en').getWeekInfo().firstDay goes 1 -> 7 ("en" is likely "en-US"). - new Intl.Locale('en-US-u-rg-gbzzzz').getWeekInfo().firstDay goes 7 -> 1 (the override names Great Britain). Adapted for 4.x: - Jint/Native/Intl/RegionPreference.cs, Data/WeekData.cs, IntlUtilities.cs: applied verbatim. RegionPreference stays internal; CanonicalizeUnicodeLocaleId goes private -> internal on an internal class. The likely-subtags step reads LikelySubtags / LikelySubtagsData, and the week step WeekData.Data.cs; all of those (and their .txt sources) are byte-identical between 4.x and main, so no data table is ported. - Jint/Native/Intl/LocalePrototype.cs: hand-ported. 4.x's getWeekInfo never asks the configured ICldrProvider (main's provider rung came with sebastienros#3357, a v5 API change not on this branch); it reads the embedded WeekData for locale.Region. That lookup now reads WeekData.GetLookupRegion(RegionPreference.Of(locale.Locale)) instead. No provider rung is added. - Jint/Native/Intl/DefaultCldrProvider.cs: main's hunk dropped. On 4.x nothing in the engine calls GetWeekInfo, so the method answers only a host that calls it directly. On main the hunk exists because that method answers the script; here it does not, and 4.x's version already disagrees with the script in other ways (a hardcoded Saturday- Sunday weekend, which main fixed in sebastienros#3357). Changing only its region would move a public method's answer with no script-visible effect and leave it half-corrected ("fa" would get Iran's Saturday with a Saturday-Sunday weekend). - Jint.Tests/Runtime/IntlLocaleRegionPreferenceTests.cs: transcribed NUnit -> xUnit v3 ([TestCase] -> [Theory] + [InlineData], [Test] -> [Fact]). Main's two provider tests are dropped: one subclasses DefaultCldrProvider, which is sealed on 4.x, to test the provider rung 4.x does not have; the other tests the DefaultCldrProvider hunk not ported here. - Jint.Tests.Test262/Test262Harness.settings.json: the same four getWeekInfo exclusions 4.x carried are removed; all four files exist in 4.x's pin (3655e746). - Jint.Tests/SpecAnchors.txt, docs/guide/migrating-to-v5.md: dropped; neither exists on 4.x. Evidence: - IntlLocaleRegionPreferenceTests on unfixed 4.x: net10.0 13 failed, 13 passed of 26; net472 13 failed, 13 passed of 26 (the same 13 cases on both). - With the fix: net10.0 26/26 passed; net472 26/26 passed. - test262 intl402/Locale/prototype/getWeekInfo/{likely-subtags-region,region-override, region-priority,subdivision-region}.js with the exclusions removed: unfixed, all 8 cases (strict and sloppy) fail, e.g. 'getWeekInfo() for "en-US-u-rg-dezzzz" should return firstDay that matches the override region Expected SameValue(«7», «1»)'; fixed, all 8 pass (22/22 getWeekInfo cases). - Full solution, one dotnet test -c Release run: Jint.Tests 7639 passed / 4 skipped (net10.0) and 7554 / 4 (net472); Jint.Tests.PublicInterface 1874 / 9 (net10.0) and 1866 / 9 (net472), public-API Verify snapshots unchanged; Jint.Tests.CommonScripts 28 / 0 on both; Jint.Tests.SourceGenerators 52 / 0. No failures in any of them. - test262 (4.x pin 3655e746), from that same run: 102,507 passed, 2 failed, 175 skipped. The two were staging/sm/Array/toSpliced-dense.js, strict and sloppy, both 30 s timeouts under load (the known flake); re-run alone, both pass in 1 s. Net: 102,509 / 0 / 175 - the 4.x control's 102,501 / 0 / 183 plus the 8 cases (4 files x strict and sloppy) the removed exclusions had been skipping. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PanPJbBD7pQC9fRiTpHxvs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #4163 (commit
ad440908afe557a2bab81c9420d60753b83d62d3) to4.x.Base:
4.xat6b39fa0760d700ce13180ed9ee0a250b082d19c3.What it fixes
Intl.Locale.prototype.getWeekInforead CLDR's week data for the tag's region subtag and nothing else. A tag without a region subtag therefore got the world's week (001), and the-u-rg-and-u-sd-keywords were ignored.It now picks the region the way RegionPreference and WeekInfoOfLocale do, in this order:
-u-rg-override, if CLDR has week data for it-u-sd-subdivision's region001Both
firstDayandweekendare read for that region. A-u-fw-keyword still wins forfirstDay.What changes for a script. Both new answers are what the specification and every browser give:
What the pick carried and what it did not
Jint/Native/Intl/RegionPreference.csinternalJint/Native/Intl/Data/WeekData.csGetLookupRegion,internal)Jint/Native/Intl/IntlUtilities.csCanonicalizeUnicodeLocaleIdgoesprivate→internal, on aninternalclassJint/Native/Intl/LocalePrototype.csJint/Native/Intl/DefaultCldrProvider.csJint.Tests/Runtime/IntlLocaleRegionPreferenceTests.cs[TestCase]→[Theory]+[InlineData],[Test]→[Fact]). Main's two provider tests are dropped (below)Jint.Tests.Test262/Test262Harness.settings.jsongetWeekInfoexclusions are removed. 4.x carried them too, and all four files exist in 4.x's pin3655e746Jint.Tests/SpecAnchors.txt,docs/guide/migrating-to-v5.mdThe provider rung
On main,
getWeekInfoasks the configuredICldrProvider.GetWeekInfofirst, and only falls back to the embedded CLDR data when the provider returnsnull. Main added that in #3357, a v5 change that also removed public members, so it is not on this branch. 4.x'sgetWeekInfonever asks the provider. It reads the embeddedWeekDataforlocale.Region. The port changes only that lookup, toWeekData.GetLookupRegion(RegionPreference.Of(locale.Locale)). It adds no provider rung.Main's hunk to
DefaultCldrProvider.GetWeekInfois left out. Nothing in the 4.x engine calls that method, so only a host calling it directly throughICldrProvidercan see it. Main changed it because on main that method answers the script. Here it does not. It also already disagrees with the script in another way: it returns a hardcoded Saturday–Sunday weekend for every region, which main fixed in #3357. Fixing only its region would change a public method's answer with nothing in script depending on it, and would leave it half-corrected:"fa"would get Iran's Saturday first day with a Saturday–Sunday weekend. For the same reason, main's two tests that need a provider are not ported. One subclassesDefaultCldrProvider, which issealedon 4.x, to test the provider rung. The other tests the dropped hunk.The likely-subtags data
The Add Likely Subtags step reads
Data/LikelySubtags.cs/LikelySubtagsData.cs/LikelySubtags.txt. The week lookup readsData/WeekData.Data.cs/WeekData.txt. The keyword regions are canonicalized throughLocaleData. All of these are byte-identical between4.xandmain(git diff upstream/4.x upstream/main -- Jint/Native/Intl/Data/touches none of them), so no data table comes with this port.Verification
The ported tests (26 cases) ran first against unfixed
4.x(test file only), then against the fixed tree:The four test262 files, each in strict and sloppy mode (8 cases), with the exclusions removed:
LocalePrototypelookup reverted tolocale.Region): all 8 fail. For example,getWeekInfo() for "en-US-u-rg-dezzzz" should return firstDay that matches the override region Expected SameValue(«7», «1»), andgetWeekInfo() for "th" should return firstDay that matches the likely region Expected SameValue(«1», «7»).getWeekInfocases (22/22).Full solution, one
dotnet test -c Releaserun:Jint.TestsJint.Tests.PublicInterface(incl. the public-API snapshot)Jint.Tests.CommonScriptsJint.Tests.SourceGeneratorsJint.Tests.Test262(pin3655e746)The public-API snapshots pass untouched, and no
.receivedfile was written. Everything this change touches isinternalorprivate.test262. Both failures were
staging/sm/Array/toSpliced-dense.js, strict and sloppy. Each hit the 30 s timeout under load; this is one of the known load flakes. Re-run alone with--filter "Name~toSpliced-dense.js", both pass in 1 s. The net result is 102,509 passed / 0 failed / 175 skipped. That is the4.xcontrol's 102,501 / 0 / 183, plus the 8 cases (4 files × strict and sloppy) that the removed exclusions had been skipping.🤖 Generated with Claude Code
https://claude.ai/code/session_01PanPJbBD7pQC9fRiTpHxvs