mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
js: Implement pretty-printing of Temporal.PlainDateTime objects
This commit is contained in:
parent
93e52f6ad8
commit
40580696a6
Notes:
sideshowbarker
2024-07-18 08:33:01 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/40580696a6f Pull-request: https://github.com/SerenityOS/serenity/pull/8940 Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 10 additions and 0 deletions
|
@ -45,6 +45,7 @@
|
|||
#include <LibJS/Runtime/Temporal/Duration.h>
|
||||
#include <LibJS/Runtime/Temporal/Instant.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDate.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
||||
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -461,6 +462,13 @@ static void print_temporal_plain_date(JS::Object const& object, HashTable<JS::Ob
|
|||
out(" \033[34;1m{:04}-{:02}-{:02}\033[0m", plain_date.iso_year(), plain_date.iso_month(), plain_date.iso_day());
|
||||
}
|
||||
|
||||
static void print_temporal_plain_date_time(JS::Object const& object, HashTable<JS::Object*>&)
|
||||
{
|
||||
auto& plain_date_time = static_cast<JS::Temporal::PlainDateTime const&>(object);
|
||||
print_type("Temporal.PlainDateTime");
|
||||
out(" \033[34;1m{:04}-{:02}-{:02} {:02}:{:02}:{:02}.{:03}{:03}{:03}\033[0m", plain_date_time.iso_year(), plain_date_time.iso_month(), plain_date_time.iso_day(), plain_date_time.iso_hour(), plain_date_time.iso_minute(), plain_date_time.iso_second(), plain_date_time.iso_millisecond(), plain_date_time.iso_microsecond(), plain_date_time.iso_nanosecond());
|
||||
}
|
||||
|
||||
static void print_temporal_time_zone(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
|
||||
{
|
||||
auto& time_zone = static_cast<JS::Temporal::TimeZone const&>(object);
|
||||
|
@ -538,6 +546,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
|
|||
return print_temporal_instant(object, seen_objects);
|
||||
if (is<JS::Temporal::PlainDate>(object))
|
||||
return print_temporal_plain_date(object, seen_objects);
|
||||
if (is<JS::Temporal::PlainDateTime>(object))
|
||||
return print_temporal_plain_date_time(object, seen_objects);
|
||||
if (is<JS::Temporal::TimeZone>(object))
|
||||
return print_temporal_time_zone(object, seen_objects);
|
||||
return print_object(object, seen_objects);
|
||||
|
|
Loading…
Reference in a new issue