summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-01 17:55:44 +0100
committerLinus Groh <mail@linusgroh.de>2021-08-01 20:31:31 +0100
commit1f5098f61eea116d50cfdc735fc02b2294c1a1d7 (patch)
tree954cfc8c5e6c11c81589bb5f6c401fd5fd1f9be5 /Userland
parentfa0d6d1045bf8bd59be0c45541349846c64b5f8e (diff)
downloadserenity-1f5098f61eea116d50cfdc735fc02b2294c1a1d7.zip
LibJS: Handle ZonedDateTime in ToTemporalTimeZone
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
index 21784cbf31..627276cc79 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
@@ -14,6 +14,7 @@
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
#include <LibJS/Runtime/Temporal/TimeZone.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
+#include <LibJS/Runtime/Temporal/ZonedDateTime.h>
namespace JS::Temporal {
@@ -326,9 +327,13 @@ Object* to_temporal_time_zone(GlobalObject& global_object, Value temporal_time_z
// 1. If Type(temporalTimeZoneLike) is Object, then
if (temporal_time_zone_like.is_object()) {
- // TODO:
// a. If temporalTimeZoneLike has an [[InitializedTemporalZonedDateTime]] internal slot, then
- // i. Return temporalTimeZoneLike.[[TimeZone]].
+ if (is<ZonedDateTime>(temporal_time_zone_like.as_object())) {
+ auto& zoned_date_time = static_cast<ZonedDateTime&>(temporal_time_zone_like.as_object());
+
+ // i. Return temporalTimeZoneLike.[[TimeZone]].
+ return &zoned_date_time.time_zone();
+ }
// b. If ? HasProperty(temporalTimeZoneLike, "timeZone") is false, return temporalTimeZoneLike.
auto has_property = temporal_time_zone_like.as_object().has_property(vm.names.timeZone);