summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-01 18:16:47 +0100
committerLinus Groh <mail@linusgroh.de>2021-08-01 20:31:31 +0100
commit0990c23fc31cd5e9e90b06697604dbd3150ea4fd (patch)
treee336502972db01d2266b2df90d34c13f03aec9e9 /Userland
parenta06bd451d429be4f3fda7e02be074d430edb78a1 (diff)
downloadserenity-0990c23fc31cd5e9e90b06697604dbd3150ea4fd.zip
js: Implement pretty-printing of Temporal.ZonedDateTime objects
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/js.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 6b27295386..bd5aef8b8e 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -48,6 +48,7 @@
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
#include <LibJS/Runtime/Temporal/PlainTime.h>
#include <LibJS/Runtime/Temporal/TimeZone.h>
+#include <LibJS/Runtime/Temporal/ZonedDateTime.h>
#include <LibJS/Runtime/TypedArray.h>
#include <LibJS/Runtime/Value.h>
#include <LibLine/Editor.h>
@@ -489,6 +490,18 @@ static void print_temporal_time_zone(JS::Object const& object, HashTable<JS::Obj
}
}
+static void print_temporal_zoned_date_time(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
+{
+ auto& zoned_date_time = static_cast<JS::Temporal::ZonedDateTime const&>(object);
+ print_type("Temporal.ZonedDateTime");
+ out("\n epochNanoseconds: ");
+ print_value(&zoned_date_time.nanoseconds(), seen_objects);
+ out("\n timeZone: ");
+ print_value(&zoned_date_time.time_zone(), seen_objects);
+ out("\n calendar: ");
+ print_value(&zoned_date_time.calendar(), seen_objects);
+}
+
static void print_primitive_wrapper_object(FlyString const& name, JS::Object const& object, HashTable<JS::Object*>& seen_objects)
{
// BooleanObject, NumberObject, StringObject
@@ -560,6 +573,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_temporal_plain_time(object, seen_objects);
if (is<JS::Temporal::TimeZone>(object))
return print_temporal_time_zone(object, seen_objects);
+ if (is<JS::Temporal::ZonedDateTime>(object))
+ return print_temporal_zoned_date_time(object, seen_objects);
return print_object(object, seen_objects);
}