mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Respect the user-provided time zone in Intl.DateTimeFormat
Also update some DateTimeFormat tests to explicitly set the time zone (usually to UTC). This was already done for most tests, but some were missed.
This commit is contained in:
committed by
Linus Groh
parent
8987deb984
commit
d64ea13565
Notes:
sideshowbarker
2024-07-17 21:02:31 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d64ea13565e Pull-request: https://github.com/SerenityOS/serenity/pull/11822 Reviewed-by: https://github.com/linusg
@@ -1492,15 +1492,14 @@ ThrowCompletionOr<Array*> format_date_time_range_to_parts(GlobalObject& global_o
|
||||
}
|
||||
|
||||
// 11.1.14 ToLocalTime ( t, calendar, timeZone ), https://tc39.es/ecma402/#sec-tolocaltime
|
||||
ThrowCompletionOr<LocalTime> to_local_time(GlobalObject& global_object, double time, StringView calendar, [[maybe_unused]] StringView time_zone)
|
||||
ThrowCompletionOr<LocalTime> to_local_time(GlobalObject& global_object, double time, StringView calendar, StringView time_zone)
|
||||
{
|
||||
// 1. Assert: Type(t) is Number.
|
||||
|
||||
// 2. If calendar is "gregory", then
|
||||
if (calendar == "gregory"sv) {
|
||||
// a. Let timeZoneOffset be the value calculated according to LocalTZA(t, true) where the local time zone is replaced with timezone timeZone.
|
||||
// FIXME: Implement LocalTZA when timezones other than UTC are supported.
|
||||
double time_zone_offset = 0;
|
||||
double time_zone_offset = local_tza(time, true, time_zone);
|
||||
|
||||
// b. Let tz be the time value t + timeZoneOffset.
|
||||
double zoned_time = time + time_zone_offset;
|
||||
|
||||
Reference in New Issue
Block a user