Commit graph

6 commits

Author SHA1 Message Date
Andrew Kaster
6b1a346fad LibUnicode: Generate FFI bindings with cbindgen
This places the exported structs and functions in the Unicode::FFI
namespace.
2026-03-18 08:36:13 -04:00
Timothy Flynn
ef899027c5 LibUnicode: Use a calendar with icu4x glue to format lunisolar calendars
Commit 86c8a57794 caused one regression in
test/intl402/DateTimeFormat. It is expected that Intl.DateTimeFormat and
Temporal produce consistent results.

Due to the píngqì approximation implemented in icu4x, it actually does
not totally align with icu4c for lunisolar calendars at extreme dates.
Ideally, icu4x will one day support all Intl.DateTimeFormat operations
as well. But for now, the fix is to create a custom icu::Calendar class
for lunisolar calendars that pipes calculations to icu4x.
2026-03-12 17:29:59 -05:00
Timothy Flynn
101fee6cb2 LibJS+LibUnicode: Rename a LibUnicode FFI function for clarity
There will be an extremely similar function that accepts a calendar year
rather than ISO year in a subsequent commit. Rename the ISO year variant
so that they are more distinguishable.
2026-03-12 17:29:59 -05:00
Timothy Flynn
397be77866 LibJS+LibUnicode: Migrate MonthCode and its utilities to LibUnicode
Will be used in a Chinese/Dangi calendar implementation.
2026-03-12 17:29:59 -05:00
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