1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:38:12 +00:00

js: Implement pretty-printing of Temporal.ZonedDateTime objects

This commit is contained in:
Linus Groh 2021-08-01 18:16:47 +01:00
parent a06bd451d4
commit 0990c23fc3

View file

@ -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);
}