diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-01-19 14:18:02 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-19 21:20:41 +0000 |
commit | 70f49d06969c9faf2ed65b745a75e44dbc8b4915 (patch) | |
tree | 53c617f8962ba8d5373815b43f14c28e47b672b6 /Userland/Libraries/LibJS/Runtime | |
parent | 42c9c57141b33845e63f8028b18ccc71223c2297 (diff) | |
download | serenity-70f49d06969c9faf2ed65b745a75e44dbc8b4915.zip |
LibJS+LibTimeZone+LibUnicode: Indicate whether a time zone is in DST
Return whether the time zone is in DST during the provided time from
TimeZone::get_time_zone_offset,
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Date.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 77c251350b..486aa00a43 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -286,7 +286,8 @@ double local_tza(double time, [[maybe_unused]] bool is_utc, Optional<StringView> auto time_since_epoch = Value(time).is_finite_number() ? AK::Time::from_milliseconds(time) : AK::Time::max(); auto maybe_offset = TimeZone::get_time_zone_offset(time_zone, time_since_epoch); - return maybe_offset.value_or(0) * 1000; + + return maybe_offset.has_value() ? static_cast<double>(maybe_offset->seconds) * 1000 : 0; } // 21.4.1.8 LocalTime ( t ), https://tc39.es/ecma262/#sec-localtime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 6d604ae84e..8754e7f906 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -175,10 +175,10 @@ i64 get_iana_time_zone_offset_nanoseconds(BigInt const& epoch_nanoseconds, Strin else time = Time::from_seconds(*seconds.to_base(10).to_int<i64>()); - auto offset_seconds = ::TimeZone::get_time_zone_offset(*time_zone, time); - VERIFY(offset_seconds.has_value()); + auto offset = ::TimeZone::get_time_zone_offset(*time_zone, time); + VERIFY(offset.has_value()); - return *offset_seconds * 1'000'000'000; + return offset->seconds * 1'000'000'000; } // 11.6.5 GetIANATimeZoneNextTransition ( epochNanoseconds, timeZoneIdentifier ), https://tc39.es/proposal-temporal/#sec-temporal-getianatimezonenexttransition |