diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp index 342467aba9..1450b11fa8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp @@ -201,7 +201,7 @@ ThrowCompletionOr create_temporal_year_month(VM& vm, i32 iso_ye } // 9.5.6 TemporalYearMonthToString ( yearMonth, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporalyearmonthtostring -ThrowCompletionOr temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar) +ThrowCompletionOr temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar) { // 1. Assert: Type(yearMonth) is Object. // 2. Assert: yearMonth has an [[InitializedTemporalYearMonth]] internal slot. @@ -209,16 +209,16 @@ ThrowCompletionOr temporal_year_month_to_string(VM& vm, PlainY // 3. Let year be ! PadISOYear(yearMonth.[[ISOYear]]). // 4. Let month be ToZeroPaddedDecimalString(yearMonth.[[ISOMonth]], 2). // 5. Let result be the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and month. - auto result = DeprecatedString::formatted("{}-{:02}", MUST_OR_THROW_OOM(pad_iso_year(vm, year_month.iso_year())), year_month.iso_month()); + auto result = TRY_OR_THROW_OOM(vm, String::formatted("{}-{:02}", MUST_OR_THROW_OOM(pad_iso_year(vm, year_month.iso_year())), year_month.iso_month())); // 6. Let calendarID be ? ToString(yearMonth.[[Calendar]]). - auto calendar_id = TRY(Value(&year_month.calendar()).to_deprecated_string(vm)); + auto calendar_id = TRY(Value(&year_month.calendar()).to_string(vm)); // 7. If showCalendar is one of "always" or "critical", or if calendarID is not "iso8601", then if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601") { // a. Let day be ToZeroPaddedDecimalString(yearMonth.[[ISODay]], 2). // b. Set result to the string-concatenation of result, the code unit 0x002D (HYPHEN-MINUS), and day. - result = DeprecatedString::formatted("{}-{:02}", result, year_month.iso_day()); + result = TRY_OR_THROW_OOM(vm, String::formatted("{}-{:02}", result, year_month.iso_day())); } // 8. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar). @@ -226,7 +226,7 @@ ThrowCompletionOr temporal_year_month_to_string(VM& vm, PlainY // 9. Set result to the string-concatenation of result and calendarString. // 10. Return result. - return DeprecatedString::formatted("{}{}", result, calendar_string); + return TRY_OR_THROW_OOM(vm, String::formatted("{}{}", result, calendar_string)); } // 9.5.7 DifferenceTemporalPlainYearMonth ( operation, yearMonth, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplainyearmonth diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h index 3d06096f90..62f17686c3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2021-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -46,7 +46,7 @@ ThrowCompletionOr regulate_iso_year_month(VM&, double year, double bool iso_year_month_within_limits(i32 year, u8 month); ISOYearMonth balance_iso_year_month(double year, double month); ThrowCompletionOr create_temporal_year_month(VM&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr); -ThrowCompletionOr temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar); +ThrowCompletionOr temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar); ThrowCompletionOr difference_temporal_plain_year_month(VM&, DifferenceOperation, PlainYearMonth&, Value other, Value options); ThrowCompletionOr add_duration_to_or_subtract_duration_from_plain_year_month(VM&, ArithmeticOperation, PlainYearMonth&, Value temporal_duration_like, Value options_value);