LibJS+js: Pretty-print Date objects using the ToDateString AO
This commit is contained in:
parent
d83ce7dd0b
commit
58ccca6a9d
Notes:
sideshowbarker
2024-07-17 20:50:49 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/58ccca6a9db Pull-request: https://github.com/SerenityOS/serenity/pull/11913 Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/nico
2 changed files with 4 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <LibJS/MarkupGenerator.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/Date.h>
|
||||
#include <LibJS/Runtime/DatePrototype.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
|
@ -141,7 +142,7 @@ void MarkupGenerator::function_to_html(const Object& function, StringBuilder& ht
|
|||
|
||||
void MarkupGenerator::date_to_html(const Object& date, StringBuilder& html_output, HashTable<Object*>&)
|
||||
{
|
||||
html_output.appendff("Date {}", static_cast<const JS::Date&>(date).string());
|
||||
html_output.appendff("Date {}", JS::to_date_string(static_cast<JS::Date const&>(date).date_value()));
|
||||
}
|
||||
|
||||
void MarkupGenerator::error_to_html(const Object& object, StringBuilder& html_output, HashTable<Object*>&)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <LibJS/Runtime/BooleanObject.h>
|
||||
#include <LibJS/Runtime/DataView.h>
|
||||
#include <LibJS/Runtime/Date.h>
|
||||
#include <LibJS/Runtime/DatePrototype.h>
|
||||
#include <LibJS/Runtime/ECMAScriptFunctionObject.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
|
@ -311,7 +312,7 @@ static void print_function(JS::Object const& object, HashTable<JS::Object*>&)
|
|||
static void print_date(JS::Object const& object, HashTable<JS::Object*>&)
|
||||
{
|
||||
print_type("Date");
|
||||
js_out(" \033[34;1m{}\033[0m", static_cast<JS::Date const&>(object).string());
|
||||
js_out(" \033[34;1m{}\033[0m", JS::to_date_string(static_cast<JS::Date const&>(object).date_value()));
|
||||
}
|
||||
|
||||
static void print_error(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
|
||||
|
|
Loading…
Add table
Reference in a new issue