mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
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.
This commit is contained in:
Notes:
github-actions[bot]
2026-03-11 11:11:18 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/86c8a577945 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8356 Reviewed-by: https://github.com/shannonbooth
@@ -628,7 +628,15 @@ static void apply_time_zone_to_formatter(icu::SimpleDateFormat& formatter, icu::
|
||||
auto* calendar = icu::Calendar::createInstance(time_zone_data->time_zone(), locale, status);
|
||||
verify_icu_success(status);
|
||||
|
||||
CalendarData::adjust_time_range_for_proleptic_calendar(*calendar);
|
||||
if (auto* gregorian_calendar = as_if<icu::GregorianCalendar>(*calendar)) {
|
||||
// https://tc39.es/ecma262/#sec-time-values-and-time-range
|
||||
// A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds.
|
||||
static constexpr double ECMA_262_MINIMUM_TIME = -8.64E15;
|
||||
|
||||
gregorian_calendar->setGregorianChange(ECMA_262_MINIMUM_TIME, status);
|
||||
verify_icu_success(status);
|
||||
}
|
||||
|
||||
formatter.adoptCalendar(calendar);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user