diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 32beb7f174..abd864364a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -230,17 +230,17 @@ StringView negate_temporal_rounding_mode(StringView rounding_mode) } // 13.8 ToTemporalOffset ( options, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloffset -ThrowCompletionOr to_temporal_offset(VM& vm, Object const* options, DeprecatedString const& fallback) +ThrowCompletionOr to_temporal_offset(VM& vm, Object const* options, StringView fallback) { // 1. If options is undefined, return fallback. if (options == nullptr) - return fallback; + return TRY_OR_THROW_OOM(vm, String::from_utf8(fallback)); // 2. Return ? GetOption(options, "offset", "string", « "prefer", "use", "ignore", "reject" », fallback). - auto option = TRY(get_option(vm, *options, vm.names.offset, OptionType::String, { "prefer"sv, "use"sv, "ignore"sv, "reject"sv }, fallback.view())); + auto option = TRY(get_option(vm, *options, vm.names.offset, OptionType::String, { "prefer"sv, "use"sv, "ignore"sv, "reject"sv }, fallback)); VERIFY(option.is_string()); - return TRY(option.as_string().deprecated_string()); + return option.as_string().utf8_string(); } // 13.9 ToCalendarNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-tocalendarnameoption diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 290b25ae0b..8ea2b4fc41 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -139,7 +139,7 @@ ThrowCompletionOr to_temporal_overflow(VM&, Object const* options); ThrowCompletionOr to_temporal_disambiguation(VM&, Object const* options); ThrowCompletionOr to_temporal_rounding_mode(VM&, Object const& normalized_options, StringView fallback); StringView negate_temporal_rounding_mode(StringView rounding_mode); -ThrowCompletionOr to_temporal_offset(VM&, Object const* options, DeprecatedString const& fallback); +ThrowCompletionOr to_temporal_offset(VM&, Object const* options, StringView fallback); ThrowCompletionOr to_calendar_name_option(VM&, Object const& normalized_options); ThrowCompletionOr to_time_zone_name_option(VM&, Object const& normalized_options); ThrowCompletionOr to_show_offset_option(VM&, Object const& normalized_options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 3dc5995f88..0ab087778c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2021-2023, Linus Groh * Copyright (c) 2021, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause @@ -250,7 +250,7 @@ ThrowCompletionOr to_temporal_zoned_date_time(VM& vm, Value item auto disambiguation = TRY(to_temporal_disambiguation(vm, options)); // 10. Let offsetOption be ? ToTemporalOffset(options, "reject"). - auto offset_option = TRY(to_temporal_offset(vm, options, "reject")); + auto offset_option = TRY(to_temporal_offset(vm, options, "reject"sv)); // 11. Let epochNanoseconds be ? InterpretISODateTimeOffset(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], offsetBehaviour, offsetNanoseconds, timeZone, disambiguation, offsetOption, matchBehaviour). auto* epoch_nanoseconds = TRY(interpret_iso_date_time_offset(vm, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, offset_behavior, offset_nanoseconds, time_zone, disambiguation, offset_option, match_behavior)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index efd84a930a..0efa6616f3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2021-2023, Linus Groh * Copyright (c) 2021, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause @@ -88,7 +88,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimeConstructor::from) (void)TRY(to_temporal_disambiguation(vm, options)); // c. Perform ? ToTemporalOffset(options, "reject"). - (void)TRY(to_temporal_offset(vm, options, "reject")); + (void)TRY(to_temporal_offset(vm, options, "reject"sv)); // d. Return ! CreateTemporalZonedDateTime(item.[[Nanoseconds]], item.[[TimeZone]], item.[[Calendar]]). return MUST(create_temporal_zoned_date_time(vm, item_object.nanoseconds(), item_object.time_zone(), item_object.calendar()));