mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
js: Implement pretty-printing of Temporal.ZonedDateTime objects
This commit is contained in:
parent
a06bd451d4
commit
0990c23fc3
Notes:
sideshowbarker
2024-07-18 07:37:41 +09:00
Author: https://github.com/linusg
Commit: 0990c23fc3
Pull-request: https://github.com/SerenityOS/serenity/pull/9160
Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 15 additions and 0 deletions
|
@ -48,6 +48,7 @@
|
||||||
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
||||||
#include <LibJS/Runtime/Temporal/PlainTime.h>
|
#include <LibJS/Runtime/Temporal/PlainTime.h>
|
||||||
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
||||||
|
#include <LibJS/Runtime/Temporal/ZonedDateTime.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibJS/Runtime/Value.h>
|
#include <LibJS/Runtime/Value.h>
|
||||||
#include <LibLine/Editor.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)
|
static void print_primitive_wrapper_object(FlyString const& name, JS::Object const& object, HashTable<JS::Object*>& seen_objects)
|
||||||
{
|
{
|
||||||
// BooleanObject, NumberObject, StringObject
|
// 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);
|
return print_temporal_plain_time(object, seen_objects);
|
||||||
if (is<JS::Temporal::TimeZone>(object))
|
if (is<JS::Temporal::TimeZone>(object))
|
||||||
return print_temporal_time_zone(object, seen_objects);
|
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);
|
return print_object(object, seen_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue