From 7c66c5f12d720ed687b9483cd8f7950e90203f1b Mon Sep 17 00:00:00 2001 From: Om Prakaash Date: Thu, 18 May 2023 17:46:01 -0700 Subject: [PATCH] LibJS: Replace a DeprecatedString with String Refactors Date class to use String instead of DeprecatedString. Changes use of the Date class in DatePrototype accordingly. --- Userland/Libraries/LibJS/Runtime/Date.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Date.h | 2 +- Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index df1ff90e3f..c64e61b40f 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -34,7 +34,7 @@ Date::Date(double date_value, Object& prototype) { } -DeprecatedString Date::iso_date_string() const +ErrorOr Date::iso_date_string() const { int year = year_from_time(m_date_value); @@ -59,7 +59,7 @@ DeprecatedString Date::iso_date_string() const builder.appendff("{:03}", ms_from_time(m_date_value)); builder.append('Z'); - return builder.to_deprecated_string(); + return builder.to_string(); } // DayWithinYear(t), https://tc39.es/ecma262/#eqn-DayWithinYear diff --git a/Userland/Libraries/LibJS/Runtime/Date.h b/Userland/Libraries/LibJS/Runtime/Date.h index 358752c06e..80b781550a 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.h +++ b/Userland/Libraries/LibJS/Runtime/Date.h @@ -23,7 +23,7 @@ public: double date_value() const { return m_date_value; } void set_date_value(double value) { m_date_value = value; } - DeprecatedString iso_date_string() const; + ErrorOr iso_date_string() const; private: Date(double date_value, Object& prototype); diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index d7d5d05fd4..d6f9425cf6 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -967,7 +967,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string) if (!Value(this_object->date_value()).is_finite_number()) return vm.throw_completion(ErrorType::InvalidTimeValue); - auto string = this_object->iso_date_string(); + auto string = TRY_OR_THROW_OOM(vm, this_object->iso_date_string()); return PrimitiveString::create(vm, move(string)); }