diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 648ad11a33..ac25bb0276 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -282,7 +282,7 @@ ThrowCompletionOr create_temporal_zoned_date_time(VM& vm, BigInt } // 6.5.4 TemporalZonedDateTimeToString ( zonedDateTime, precision, showCalendar, showTimeZone, showOffset [ , increment, unit, roundingMode ] ), https://tc39.es/proposal-temporal/#sec-temporal-temporalzoneddatetimetostring -ThrowCompletionOr temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional increment, Optional unit, Optional rounding_mode) +ThrowCompletionOr temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional increment, Optional unit, Optional rounding_mode) { // 1. If increment is not present, set increment to 1. if (!increment.has_value()) @@ -330,12 +330,12 @@ ThrowCompletionOr temporal_zoned_date_time_to_string(VM& vm, Z offset_string = MUST_OR_THROW_OOM(format_iso_time_zone_offset_string(vm, offset_ns)); } - DeprecatedString time_zone_string; + String time_zone_string; // 12. If showTimeZone is "never", then if (show_time_zone == "never"sv) { // a. Let timeZoneString be the empty String. - time_zone_string = DeprecatedString::empty(); + time_zone_string = {}; } // 13. Else, else { @@ -346,14 +346,14 @@ ThrowCompletionOr temporal_zoned_date_time_to_string(VM& vm, Z auto flag = show_time_zone == "critical"sv ? "!"sv : ""sv; // c. Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), flag, timeZoneID, and the code unit 0x005D (RIGHT SQUARE BRACKET). - time_zone_string = DeprecatedString::formatted("[{}{}]", flag, time_zone_id); + time_zone_string = TRY_OR_THROW_OOM(vm, String::formatted("[{}{}]", flag, time_zone_id)); } // 14. Let calendarString be ? MaybeFormatCalendarAnnotation(zonedDateTime.[[Calendar]], showCalendar). auto calendar_string = TRY(maybe_format_calendar_annotation(vm, &zoned_date_time.calendar(), show_calendar)); // 15. Return the string-concatenation of dateTimeString, offsetString, timeZoneString, and calendarString. - return DeprecatedString::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string); + return TRY_OR_THROW_OOM(vm, String::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string)); } // 6.5.5 AddZonedDateTime ( epochNanoseconds, timeZone, calendar, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-addzoneddatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h index 0c70fe8732..d384c7c3d6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2021-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -55,7 +55,7 @@ enum class MatchBehavior { ThrowCompletionOr interpret_iso_date_time_offset(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, OffsetBehavior offset_behavior, double offset_nanoseconds, Value time_zone, StringView disambiguation, StringView offset_option, MatchBehavior match_behavior); ThrowCompletionOr to_temporal_zoned_date_time(VM&, Value item, Object const* options = nullptr); ThrowCompletionOr create_temporal_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); -ThrowCompletionOr temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional increment = {}, Optional unit = {}, Optional rounding_mode = {}); +ThrowCompletionOr temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional increment = {}, Optional unit = {}, Optional rounding_mode = {}); ThrowCompletionOr add_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Value time_zone, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options = nullptr); ThrowCompletionOr difference_zoned_date_time(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, Object& time_zone, Object& calendar, StringView largest_unit, Object const& options); ThrowCompletionOr nanoseconds_to_days(VM&, Crypto::SignedBigInteger nanoseconds, Value relative_to);