From 96167e39e7d70d98f09b3a900086420df6825f83 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 7 Jul 2021 17:43:17 +0100 Subject: [PATCH] js: Implement pretty-printing of Temporal.Instant objects --- Userland/Utilities/js.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index bdda3f4915..dd6ffd3daf 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -426,6 +427,15 @@ static void print_data_view(JS::Object const& object, HashTable& se out(" @ {:p}", data_view.viewed_array_buffer()); } +static void print_temporal_instant(JS::Object const& object, HashTable& seen_objects) +{ + auto& instant = static_cast(object); + print_type("Temporal.Instant"); + // FIXME: Print human readable date and time, like in print_date() - ideally handling arbitrarily large values since we get a bigint. + out("\n nanoseconds: "); + print_value(&instant.nanoseconds(), seen_objects); +} + static void print_temporal_time_zone(JS::Object const& object, HashTable& seen_objects) { auto& time_zone = static_cast(object); @@ -495,6 +505,8 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_primitive_wrapper_object("Number", object, seen_objects); if (is(object)) return print_primitive_wrapper_object("Boolean", object, seen_objects); + if (is(object)) + return print_temporal_instant(object, seen_objects); if (is(object)) return print_temporal_time_zone(object, seen_objects); return print_object(object, seen_objects);