summaryrefslogtreecommitdiff
path: root/Userland/Utilities/js.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-01-25 12:05:20 -0500
committerLinus Groh <mail@linusgroh.de>2022-01-25 19:02:59 +0000
commit47e9e7c2d0aa9610f66fb5c0c1061466bf62c29c (patch)
tree104bc72cb2c0c4839a173dc1c6bca330cf216f6f /Userland/Utilities/js.cpp
parenta2e31ed73687c975d552c4a6a8da7147a7efe0e9 (diff)
downloadserenity-47e9e7c2d0aa9610f66fb5c0c1061466bf62c29c.zip
js: Implement pretty-printing of Intl.RelativeTimeFormat
Diffstat (limited to 'Userland/Utilities/js.cpp')
-rw-r--r--Userland/Utilities/js.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 66bec4ccb7..199c61da5a 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -37,6 +37,7 @@
#include <LibJS/Runtime/Intl/ListFormat.h>
#include <LibJS/Runtime/Intl/Locale.h>
#include <LibJS/Runtime/Intl/NumberFormat.h>
+#include <LibJS/Runtime/Intl/RelativeTimeFormat.h>
#include <LibJS/Runtime/JSONObject.h>
#include <LibJS/Runtime/Map.h>
#include <LibJS/Runtime/NativeFunction.h>
@@ -764,6 +765,20 @@ static void print_intl_date_time_format(JS::Object& object, HashTable<JS::Object
});
}
+static void print_intl_relative_time_format(JS::Object& object, HashTable<JS::Object*>& seen_objects)
+{
+ auto& date_time_format = static_cast<JS::Intl::RelativeTimeFormat&>(object);
+ print_type("Intl.RelativeTimeFormat");
+ js_out("\n locale: ");
+ print_value(js_string(object.vm(), date_time_format.locale()), seen_objects);
+ js_out("\n numberingSystem: ");
+ print_value(js_string(object.vm(), date_time_format.numbering_system()), seen_objects);
+ js_out("\n style: ");
+ print_value(js_string(object.vm(), date_time_format.style_string()), seen_objects);
+ js_out("\n numeric: ");
+ print_value(js_string(object.vm(), date_time_format.numeric_string()), seen_objects);
+}
+
static void print_primitive_wrapper_object(FlyString const& name, JS::Object const& object, HashTable<JS::Object*>& seen_objects)
{
// BooleanObject, NumberObject, StringObject
@@ -859,6 +874,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_intl_number_format(object, seen_objects);
if (is<JS::Intl::DateTimeFormat>(object))
return print_intl_date_time_format(object, seen_objects);
+ if (is<JS::Intl::RelativeTimeFormat>(object))
+ return print_intl_relative_time_format(object, seen_objects);
return print_object(object, seen_objects);
}