mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 05:48:12 +00:00
LibJS: Do not negate offset in LocalTZA for isUTC=false
In commmit 7d2834344a
, I think I combined
the definitions of the LocalTZA and UTC AOs in my head, and thought the
offset should be negated within LocalTZA. Instead, the offset should be
left untouched, and the UTC AO is responsible for doing the subtraction.
This commit is contained in:
parent
d93713b874
commit
b2aa3c9f84
2 changed files with 4 additions and 6 deletions
|
@ -317,15 +317,12 @@ u8 week_day(double t)
|
|||
}
|
||||
|
||||
// 21.4.1.7 LocalTZA ( t, isUTC ), https://tc39.es/ecma262/#sec-local-time-zone-adjustment
|
||||
double local_tza(double time, bool is_utc, Optional<StringView> time_zone_override)
|
||||
double local_tza(double time, [[maybe_unused]] bool is_utc, Optional<StringView> time_zone_override)
|
||||
{
|
||||
// The time_zone_override parameter is non-standard, but allows callers to override the system
|
||||
// time zone with a specific value without setting environment variables.
|
||||
auto time_zone = time_zone_override.value_or(TimeZone::current_time_zone());
|
||||
|
||||
auto maybe_offset = TimeZone::get_time_zone_offset(time_zone, AK::Time::from_milliseconds(time));
|
||||
auto offset = maybe_offset.value_or(0) * 1000;
|
||||
|
||||
// When isUTC is true, LocalTZA( tUTC, true ) should return the offset of the local time zone from
|
||||
// UTC measured in milliseconds at time represented by time value tUTC. When the result is added to
|
||||
// tUTC, it should yield the corresponding Number tlocal.
|
||||
|
@ -334,7 +331,8 @@ double local_tza(double time, bool is_utc, Optional<StringView> time_zone_overri
|
|||
// UTC measured in milliseconds at local time represented by Number tlocal. When the result is subtracted
|
||||
// from tlocal, it should yield the corresponding time value tUTC.
|
||||
|
||||
return is_utc ? offset : -offset;
|
||||
auto maybe_offset = TimeZone::get_time_zone_offset(time_zone, AK::Time::from_milliseconds(time));
|
||||
return maybe_offset.value_or(0) * 1000;
|
||||
}
|
||||
|
||||
// 21.4.1.8 LocalTime ( t ), https://tc39.es/ecma262/#sec-localtime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue