Timothy Flynn
86c8a57794
LibJS+LibUnicode: Use icu4x for Temporal calendar operations
...
Replace the icu4c-based calendar implementation with one built on the
icu4x Rust crate (icu_calendar).
The icu4c API does not expose the píngqì month-assignment algorithm
used by the Chinese and Dangi lunisolar calendars. Our old code had to
approximate this by walking months via epoch millisecond arithmetic and
manually tracking leap month positions, which produced incorrect month
codes and ordinal month numbers for certain years. The icu4x calendar
crate handles píngqì natively.
With this patch, which is almost a 1-to-1 mapping of ICU invocations, we
pass 100% of all Temporal test262 tests.
The end goal might be to use icu4x for all of our ICU needs. But it does
not yet provide the APIs needed for all ECMA-402 prototypes.
2026-03-11 07:09:57 -04:00
Timothy Flynn
b800c97ab8
LibJS+LibUnicode: Add support for non-ISO-8601 Temporal calendars
...
This adds international calendar support to our Temporal implementation,
using the Intl Era and Month Code Proposal as a guide. See:
https://tc39.es/proposal-intl-era-monthcode/
2026-03-09 11:40:59 +01:00
Timothy Flynn
a41f2f56a8
LibJS+LibUnicode: Migrate some Temporal calendar types to LibUnicode
...
These will be needed for calendar operations involving ICU.
2026-03-09 11:40:59 +01:00
Timothy Flynn
b322d0fe84
LibJS: Add an infallible override of ParseMonthCode
...
This will be useful to avoid needing to pass around a VM in a bunch of
AOs in a future commit.
2026-03-09 11:40:59 +01:00
Timothy Flynn
2e74b91ca1
LibJS: Pass calendar strings around as String more regularly
...
Same as commit f9fa548d43 .
These are String from the outset, so this patch is almost entirely just
changing function parameter types. This will allow us to cache calendar
objects in ICU without invoking any extra allocations.
2026-03-09 11:40:59 +01:00
Timothy Flynn
88365031f2
LibJS+LibUnicode: Implement support for handling gaps in time zones
2026-03-09 11:40:59 +01:00
Timothy Flynn
544e6ee3bb
LibJS: Use the correct error type for invalid time zone names
2026-03-09 11:40:59 +01:00
Timothy Flynn
aa435bdd7d
LibJS: Correctly parse time zones with a negative GMT offset
2026-03-09 11:40:59 +01:00
Shannon Booth
502ae99102
LibJS: Make more use of Value::is and Value::as_if
2026-02-28 10:24:37 -05:00
Timothy Flynn
cadba4c0e7
LibJS: Make more use of Value::is and Value::as_if in Temporal
2026-02-27 17:19:33 +01:00
Timothy Flynn
e95db70d2d
LibJS+LibWeb: Return GC::Ptr from Value::as_if
2026-02-27 17:19:33 +01:00
Timothy Flynn
d1ed361239
LibJS: Cache the result of parsing time zone identifiers
...
The result of parsing an identifier cannot change. It is not cheap to do
so, so let's cache the result.
This is hammered in a few test262 tests. On my machine, this reduces the
runtime of each test/staging/sm/Date/dst-offset-caching-{N}-of-8.js by
0.3 to 0.5 seconds. For example:
dst-offset-caching-1-of-8.js: Reduces from 1.2s -> 0.9s
dst-offset-caching-3-of-8.js: Reduces from 1.5s -> 1.1s
2026-02-19 09:20:15 +01:00
Timothy Flynn
6e433f0d10
LibJS: Use infallible time zone parser in a couple more locations
2026-02-19 09:20:15 +01:00
Timothy Flynn
f9fa548d43
LibJS: Pass time zone strings around as String more regularly
...
These are String from the outset, so this patch is almost entirely just
changing function parameter types. This will allow us to cache time zone
parse results without invoking any extra allocations.
2026-02-19 09:20:15 +01:00
Timothy Flynn
206a18acd4
LibJS: Use single-line if/else steps in Temporal operations
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/978311d
2026-02-14 19:47:29 +01:00
Timothy Flynn
a8345693aa
LibJS: Avoid "or if" in if-clauses in Temporal
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/e85b20b
2026-02-14 19:47:29 +01:00
Timothy Flynn
78ff593cc8
LibJS: Use "either" / "one of" when comparing multiple items in Temporal
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/5b02980
2026-02-14 19:47:29 +01:00
Timothy Flynn
d9ce90978c
LibJS: Use = for Temporal mathematical value and BigInt comparisons
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/67ca9de
2026-02-14 19:47:29 +01:00
Timothy Flynn
25ac3d2403
LibJS: Adjust language around Temporal list lengths
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1e043d6
2026-02-14 19:47:29 +01:00
Timothy Flynn
f3f8311462
LibJS: Prefer "a new empty List" instead of "an empty List" in Temporal
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/c538d83
2026-02-14 19:47:29 +01:00
Timothy Flynn
dde73e9eb7
LibJS: Remove editor's note from Temporal's ISODateToEpochDays
...
We don't tend to copy these as they won't appear in the final spec.
(These note types are different than the standard NOTE: signifiers.)
2026-02-14 19:47:29 +01:00
Timothy Flynn
1d8e03b236
LibJS: Remove redundant "the value of x" in Temporal operations
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/09e36d3
2026-02-14 19:47:29 +01:00
Timothy Flynn
ececb8c38c
LibJS: Improve note about precise division in NudgetToCalendarUnit
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/0e8220c
2026-02-14 19:47:29 +01:00
Timothy Flynn
46c864fdd3
LibJS: Remove an unreachable path in Temporal's TimeZoneEquals AO
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/a3cb4bb
2026-02-14 19:47:29 +01:00
Timothy Flynn
e73b54532f
LibJS: Refactor CalendarResolveFields parallel to NonISOResolveFields
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/b2e8299
2026-02-14 19:47:29 +01:00
Timothy Flynn
74048336df
LibJS: Remove else clauses after early returns in Temporal operations
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/e6e031f
2026-02-14 19:47:29 +01:00
Timothy Flynn
8c5fd82da9
LibJS: Replace "otherwise" with "else" in Temporal operations
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1ae3e42
2026-02-14 19:47:29 +01:00
Timothy Flynn
1fdcb5cfe5
LibJS: Fix typo in ToTemporalMonthDay
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/56828a2
2026-02-14 19:47:29 +01:00
Timothy Flynn
fc997d74cb
LibJS: Update spec numbers for Intl Temporal operations
...
Several Intl overrides were removed from the Temporal proposal some time
ago. See:
https://github.com/tc39/proposal-temporal/commit/c08f6a8
https://github.com/tc39/proposal-temporal/commit/87ba571
https://github.com/tc39/proposal-temporal/commit/b52e320
https://github.com/tc39/proposal-temporal/commit/686b216
https://github.com/tc39/proposal-temporal/commit/b125fce
2026-02-14 19:47:29 +01:00
Timothy Flynn
ef1b4a4d57
LibJS: Forbid adding/subtracting non-year/month units in PlainYearMonth
...
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/41faca4
2026-01-30 08:01:45 +01:00
Timothy Flynn
7ac2e7deea
LibJS: Split ISODateSurpasses into a couple of AOs
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/196a319
2026-01-30 08:01:45 +01:00
Timothy Flynn
eff429d490
Revert "LibJS: Move ambiguous time string handling to a separate parser"
...
This reverts commit 3f75cf270a .
This change was meant to be editorial, but it caused a regression. See:
https://github.com/tc39/proposal-temporal/commit/3ffa677
A separate test was not added here to catch this regression, because it
affects non-ISO-8601 calendars, which we do not yet implement.
2026-01-30 08:01:45 +01:00
Timothy Flynn
3fb0e69c20
LibJS: Flip validity check to an assertion in CalendarMonthDayFromFields
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/163d589
2026-01-16 14:31:31 +01:00
Timothy Flynn
076bbd4c33
LibJS: Hoist early return in CalendarDateUntil to the top
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/264e4b8
2026-01-16 14:31:31 +01:00
Timothy Flynn
6cd765c19c
LibJS: Flip validity check to an assertion in IsValidDuration
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/e65f411
2026-01-16 14:31:31 +01:00
Luke Wilde
f77b72040e
LibJS/Temporal: Implement finding time zone transitions
2026-01-16 07:00:02 -05:00
Timothy Flynn
b517e5b947
LibJS: Avoid sign negations in Temporal's DifferenceZonedDateTime
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/407fa01
2026-01-13 13:02:22 -05:00
Timothy Flynn
3eabdcf460
LibJS: Replace Temporal's BalanceISODate with AddDaysToISODate
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/b28ef08
2026-01-13 13:02:22 -05:00
Timothy Flynn
37f49d5f6d
LibJS: Use nanoseconds to normalize values in IsValidDuration
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/68004cc
https://github.com/tc39/proposal-temporal/commit/a6043aa
https://github.com/tc39/proposal-temporal/commit/1962c8b
Note that we were already performing this calculation using nanoseconds.
2025-11-21 13:52:55 +01:00
Timothy Flynn
8feabc3158
LibJS: Re-order infallible operations in GetDifferenceSettings
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/c11021a
2025-11-21 13:52:55 +01:00
Timothy Flynn
54b9ddcc80
LibJS: Use relative date in NudgeToCalendarUnit when comparing durations
...
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/17e12be
The test added here would previously crash.
2025-11-20 08:28:51 -05:00
Timothy Flynn
c7e4a99219
LibJS: Handle negativity in Temporal's ApplyUnsignedRoundingMode
...
I don't fully understand the BigInt math here, as the computation for
d1 and d2 don't align with the spec due to BigInt logic. This was
discussed a bit in SerenityOS's Discord some years ago:
https://discord.com/channels/830522505605283862/851522357734408232/978786665306918932
But some new tests in test262 indicate that we need to handle negative
values here, instead of just throwing away the sign.
2025-11-14 06:32:49 -05:00
Psychpsyo
100f37995f
Everywhere: Clean up AD-HOC and FIXME comments without colons
2025-11-13 15:56:04 +01:00
Timothy Flynn
5c0fdd371a
LibJS: Mark invocation to ParseMonthCode as infallible
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/c1f7bd5
Note the related assertion here was a bit silly. It was effectively:
if (!cond) { return; }
VERIFY(cond);
2025-11-12 16:20:04 -05:00
Timothy Flynn
041c4f4c79
LibJS: Remove unnecessary Temporal month code check
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/9110854
This change actually exposed a bug in our validator for month codes
(which is only used by this same function). We would previously allow
"M00" as a month code, which is invalid (it must be "M00L").
2025-11-12 16:20:04 -05:00
Timothy Flynn
bf3481b301
LibJS: Explicitly state integer limits for UTC offset minutes and ns
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1fdf09a
Note that the integer limits in the above commit are in spec headers,
which we don't copy to our implementation.
2025-11-12 16:20:04 -05:00
Timothy Flynn
462e7b0c87
LibJS: Introduce Time Zone Identifier Parse Records to Temporal
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/96bb9b0
Note that we already had a struct for this, but now that it has a proper
name and spec link, this renames it to match other Parse Records and
places it alongside them.
2025-11-12 16:20:04 -05:00
Timothy Flynn
aff642053a
LibJS: Set day field in CalendarYearMonthFromFields before resolution
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/a8d38c6
2025-11-06 13:47:11 -05:00
Timothy Flynn
cb6ca85564
LibJS: Handle relativeTo ZDTs that fall within second DST wallclock time
...
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1a089eb
2025-09-28 11:33:43 -04:00
Timothy Flynn
5bd867f1dc
LibJS: Revert inadvertent observable Temporal change
...
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/6274e5d
2025-09-19 11:24:02 -04:00