diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 0ba5ca1739..c390fc3d1e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -748,11 +748,11 @@ YearWeekRecord to_iso_week_of_year(i32 year, u8 month, u8 day) } // 12.2.33 ISOMonthCode ( month ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthcode -DeprecatedString iso_month_code(u8 month) +ThrowCompletionOr iso_month_code(VM& vm, u8 month) { // 1. Let numberPart be ToZeroPaddedDecimalString(month, 2). // 2. Return the string-concatenation of "M" and numberPart. - return DeprecatedString::formatted("M{:02}", month); + return TRY_OR_THROW_OOM(vm, String::formatted("M{:02}", month)); } // 12.2.34 ResolveISOMonth ( fields ), https://tc39.es/proposal-temporal/#sec-temporal-resolveisomonth @@ -804,7 +804,7 @@ ThrowCompletionOr resolve_iso_month(VM& vm, Object const& fields) auto month_code_number = MUST(Value(PrimitiveString::create(vm, move(month_code_digits))).to_integer_or_infinity(vm)); // 12. Assert: SameValue(monthCode, ISOMonthCode(monthCodeNumber)) is true. - VERIFY(month_code_string == iso_month_code(month_code_number)); + VERIFY(month_code_string.view() == TRY(iso_month_code(vm, month_code_number))); // 13. If month is not undefined and SameValue(month, monthCodeNumber) is false, throw a RangeError exception. if (!month.is_undefined() && month.as_double() != month_code_number) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h index 011088b0bc..6d9fd3b9df 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h @@ -73,7 +73,7 @@ ThrowCompletionOr calendar_equals(VM&, Object& one, Object& two); ThrowCompletionOr consolidate_calendars(VM&, Object& one, Object& two); u8 iso_days_in_month(i32 year, u8 month); YearWeekRecord to_iso_week_of_year(i32 year, u8 month, u8 day); -DeprecatedString iso_month_code(u8 month); +ThrowCompletionOr iso_month_code(VM&, u8 month); ThrowCompletionOr resolve_iso_month(VM&, Object const& fields); ThrowCompletionOr iso_date_from_fields(VM&, Object const& fields, Object const& options); ThrowCompletionOr iso_year_month_from_fields(VM&, Object const& fields, Object const& options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index 077f2d75f5..1e6ffc9493 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -301,7 +301,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_code) // NOTE: The assertion happens in iso_month() call. // 6. Return ISOMonthCode(temporalDateLike.[[ISOMonth]]). - return PrimitiveString::create(vm, iso_month_code(iso_month(temporal_date_like.as_object()))); + return PrimitiveString::create(vm, TRY(iso_month_code(vm, iso_month(temporal_date_like.as_object())))); } // 12.4.12 Temporal.Calendar.prototype.day ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.day