diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index d3c44229bf..32beb7f174 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -184,7 +184,7 @@ ThrowCompletionOr to_temporal_disambiguation(VM& vm, Object const* optio } // 13.6 ToTemporalRoundingMode ( normalizedOptions, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalroundingmode -ThrowCompletionOr to_temporal_rounding_mode(VM& vm, Object const& normalized_options, DeprecatedString const& fallback) +ThrowCompletionOr to_temporal_rounding_mode(VM& vm, Object const& normalized_options, StringView fallback) { // 1. Return ? GetOption(normalizedOptions, "roundingMode", "string", « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », fallback). auto option = TRY(get_option( @@ -200,14 +200,14 @@ ThrowCompletionOr to_temporal_rounding_mode(VM& vm, Object con "halfTrunc"sv, "halfEven"sv, }, - fallback.view())); + fallback)); VERIFY(option.is_string()); - return TRY(option.as_string().deprecated_string()); + return option.as_string().utf8_string(); } // 13.7 NegateTemporalRoundingMode ( roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-negatetemporalroundingmode -StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode) +StringView negate_temporal_rounding_mode(StringView rounding_mode) { // 1. If roundingMode is "ceil", return "floor". if (rounding_mode == "ceil"sv) @@ -1850,7 +1850,7 @@ ThrowCompletionOr get_difference_settings(VM& vm, Difference // 10. If operation is since, then if (operation == DifferenceOperation::Since) { // a. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode). - rounding_mode = negate_temporal_rounding_mode(rounding_mode); + rounding_mode = TRY_OR_THROW_OOM(vm, String::from_utf8(negate_temporal_rounding_mode(rounding_mode))); } // 11. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit). @@ -1863,7 +1863,7 @@ ThrowCompletionOr get_difference_settings(VM& vm, Difference return DifferenceSettings { .smallest_unit = smallest_unit.release_value(), .largest_unit = largest_unit.release_value(), - .rounding_mode = move(rounding_mode), + .rounding_mode = rounding_mode.to_deprecated_string(), .rounding_increment = rounding_increment, .options = *options, }; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 3fc8d9572b..290b25ae0b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -137,8 +137,8 @@ ThrowCompletionOr get_options_object(VM&, Value options); ThrowCompletionOr get_option(VM&, Object const& options, PropertyKey const& property, OptionType type, Span values, OptionDefault const&); 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, DeprecatedString const& fallback); -StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode); +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_calendar_name_option(VM&, Object const& normalized_options); ThrowCompletionOr to_time_zone_name_option(VM&, Object const& normalized_options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 13f2742a13..ab6416b03c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2021-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -216,7 +216,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round) auto& smallest_unit = *smallest_unit_value; // 7. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand"). - auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand")); + auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand"sv)); double maximum; // 8. If smallestUnit is "hour", then diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index 6043ad2e29..34ba681080 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.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 @@ -566,7 +566,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::round) auto smallest_unit = TRY(get_temporal_unit(vm, *round_to, vm.names.smallestUnit, UnitGroup::Time, TemporalUnitRequired {}, { "day"sv })); // 7. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand"). - auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand")); + auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand"sv)); // 8. Let roundingIncrement be ? ToTemporalDateTimeRoundingIncrement(roundTo, smallestUnit). auto rounding_increment = TRY(to_temporal_date_time_rounding_increment(vm, *round_to, *smallest_unit)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 54e2bff5f4..bb492a0b02 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.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 @@ -299,7 +299,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::round) auto smallest_unit = TRY(get_temporal_unit(vm, *round_to, vm.names.smallestUnit, UnitGroup::Time, TemporalUnitRequired {})); // 7. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand"). - auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand")); + auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *round_to, "halfExpand"sv)); // 8. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit). auto maximum = maximum_temporal_duration_rounding_increment(*smallest_unit); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index f242d38fd9..4cdd03e9f5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.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 @@ -1105,7 +1105,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_string) auto precision = TRY(to_seconds_string_precision(vm, *options)); // 5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc"). - auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *options, "trunc")); + auto rounding_mode = TRY(to_temporal_rounding_mode(vm, *options, "trunc"sv)); // 6. Let showCalendar be ? ToCalendarNameOption(options). auto show_calendar = TRY(to_calendar_name_option(vm, *options));