Temporal API, wrong results for yearOfWeek/weekOfYear w/ calendar:gregory
Categories
(Core :: JavaScript: Standard Library, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox141 | --- | fixed |
People
(Reporter: arshaw, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Steps to reproduce:
Test on Firefox nightly 137.0a1 (2025-02-24) (aarch64)
const lastDay2029 = Temporal.PlainDate.from('2029-12-31[u-ca=gregory]');
/*
EXPECT: 1
ACTUAL: 53
*/
console.log(lastDay2029.weekOfYear)
/*
EXPECT: 2030
ACTUAL: 2029
*/
console.log(lastDay2029.yearOfWeek)
Actual results:
See above
Expected results:
See above
Originally reported here: https://github.com/fullcalendar/temporal-polyfill/issues/53
Comment 2•6 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: Standard Library' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Assignee | ||
Comment 3•6 months ago
|
||
Can you file an issue at https://github.com/tc39/proposal-temporal/ to clarify the spec? If it is expected that the Gregorian calendar uses exactly the same week numbering system as the ISO-8601 calendar, the spec should require this behaviour. Thanks!
Updated•6 months ago
|
This is getting discussed here: https://github.com/tc39/proposal-temporal/issues/3096
Hi André, hope you are well. After digging further, I've realized the problem isn't that gregorian week numbers should/shouldn't be following iso8601, but rather the gregorian week numbers that Firefox is generating are buggy on their own right. Please see this recreation code:
d = Temporal.PlainDate.from('<insert PlainDate string>');
console.log(d.yearOfWeek + ', ' + d.weekOfYear);
Results:
PlainDate string | Day of Week | Ref Impl | Firefox |
---|---|---|---|
2029-12-30[u-ca=gregory] |
7 - Sun |
2029, 52 |
2029, 52 |
2029-12-31[u-ca=gregory] |
1 - Mon |
2030, 1 |
2029, 53 |
2030-01-01[u-ca=gregory] |
2 - Tue |
2030, 1 |
2030, 1 |
2030-01-02[u-ca=gregory] |
3 - Wed |
2030, 1 |
2030, 1 |
2030-01-03[u-ca=gregory] |
4 - Thu |
2030, 1 |
2030, 1 |
2030-01-04[u-ca=gregory] |
5 - Fri |
2030, 1 |
2030, 1 |
2030-01-05[u-ca=gregory] |
6 - Sat |
2030, 1 |
2030, 1 |
2030-01-06[u-ca=gregory] |
7 - Sun |
2030, 1 |
2030, 1 |
2030-01-07[u-ca=gregory] |
1 - Mon |
2030, 2 |
2030, 2 |
Note that Firefox is amazingly determining that week 2030, 1
only has 6 days in it!
I tried tracing the code from here -> here, and I see this is offloaded to ICU4X. All the configuration looks correct to me (firstWeekday
= Monday, minWeekDays
= 1), so could it be that this is a bug in ICU4X?
Err, maybe ICU4X isn't necessarily "buggy" but it's opinionated about week numbers spanning as far as possible until year-end.
This was discussed in the 3/6/2025 Temporal champions meeting. It's likely a bug in ICU4X not conforming to the latest CLDR. I've opened a ticket here: https://github.com/unicode-org/icu4x/issues/6247
Assignee | ||
Comment 8•3 months ago
|
||
Return undefined
per the discussions in https://github.com/tc39/proposal-temporal/issues/3096
and https://github.com/tc39/proposal-intl-era-monthcode/issues/15.
Updated•3 months ago
|
Comment 10•3 months ago
|
||
bugherder |
Updated•2 months ago
|
Description
•