mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 16:40:59 +00:00
LibJS: Fix "set it to" language to be more explicit
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/de58241
This commit is contained in:
parent
4722045e28
commit
17da627b4c
|
@ -334,7 +334,7 @@ ThrowCompletionOr<Duration*> create_temporal_duration(GlobalObject& global_objec
|
|||
if (!is_valid_duration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration);
|
||||
|
||||
// 2. If newTarget is not present, set it to %Temporal.Duration%.
|
||||
// 2. If newTarget is not present, set newTarget to %Temporal.Duration%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_duration_constructor();
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ ThrowCompletionOr<Instant*> create_temporal_instant(GlobalObject& global_object,
|
|||
// 2. Assert: ! IsValidEpochNanoseconds(epochNanoseconds) is true.
|
||||
VERIFY(is_valid_epoch_nanoseconds(epoch_nanoseconds));
|
||||
|
||||
// 3. If newTarget is not present, set it to %Temporal.Instant%.
|
||||
// 3. If newTarget is not present, set newTarget to %Temporal.Instant%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_instant_constructor();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ ThrowCompletionOr<PlainDate*> create_temporal_date(GlobalObject& global_object,
|
|||
if (!iso_date_time_within_limits(global_object, iso_year, iso_month, iso_day, 12, 0, 0, 0, 0, 0))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate);
|
||||
|
||||
// 7. If newTarget is not present, set it to %Temporal.PlainDate%.
|
||||
// 7. If newTarget is not present, set newTarget to %Temporal.PlainDate%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_plain_date_constructor();
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(GlobalObject& global
|
|||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
|
||||
}
|
||||
|
||||
// 6. If newTarget is not present, set it to %Temporal.PlainDateTime%.
|
||||
// 6. If newTarget is not present, set newTarget to %Temporal.PlainDateTime%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_plain_date_time_constructor();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -158,7 +158,7 @@ ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(GlobalObject& global
|
|||
if (!is_valid_iso_date(reference_iso_year, iso_month, iso_day))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainMonthDay);
|
||||
|
||||
// 4. If newTarget is not present, set it to %Temporal.PlainMonthDay%.
|
||||
// 4. If newTarget is not present, set newTarget to %Temporal.PlainMonthDay%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_plain_month_day_constructor();
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu
|
|||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. If overflow is not present, set it to "constrain".
|
||||
// 1. If overflow is not present, set overflow to "constrain".
|
||||
if (!overflow.has_value())
|
||||
overflow = "constrain"sv;
|
||||
|
||||
|
@ -361,7 +361,7 @@ ThrowCompletionOr<PlainTime*> create_temporal_time(GlobalObject& global_object,
|
|||
if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime);
|
||||
|
||||
// 3. If newTarget is not present, set it to %Temporal.PlainTime%.
|
||||
// 3. If newTarget is not present, set newTarget to %Temporal.PlainTime%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_plain_time_constructor();
|
||||
|
||||
|
@ -533,7 +533,7 @@ DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 micro
|
|||
|
||||
// 3. If unit is "day", then
|
||||
if (unit == "day"sv) {
|
||||
// a. If dayLengthNs is not present, set it to 8.64 × 10^13.
|
||||
// a. If dayLengthNs is not present, set dayLengthNs to 8.64 × 10^13.
|
||||
if (!day_length_ns.has_value())
|
||||
day_length_ns = 86400000000000;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -216,7 +216,7 @@ ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(GlobalObject& glob
|
|||
if (!iso_year_month_within_limits(iso_year, iso_month))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth);
|
||||
|
||||
// 5. If newTarget is not present, set it to %Temporal.PlainYearMonth%.
|
||||
// 5. If newTarget is not present, set newTarget to %Temporal.PlainYearMonth%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_plain_year_month_constructor();
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ String default_time_zone()
|
|||
// 11.6.1 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(GlobalObject& global_object, String const& identifier, FunctionObject const* new_target)
|
||||
{
|
||||
// 1. If newTarget is not present, set it to %Temporal.TimeZone%.
|
||||
// 1. If newTarget is not present, set newTarget to %Temporal.TimeZone%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_time_zone_constructor();
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(GlobalObject&
|
|||
// 2. Assert: ! IsValidEpochNanoseconds(epochNanoseconds) is true.
|
||||
VERIFY(is_valid_epoch_nanoseconds(epoch_nanoseconds));
|
||||
|
||||
// 5. If newTarget is not present, set it to %Temporal.ZonedDateTime%.
|
||||
// 5. If newTarget is not present, set newTarget to %Temporal.ZonedDateTime%.
|
||||
if (!new_target)
|
||||
new_target = global_object.temporal_zoned_date_time_constructor();
|
||||
|
||||
|
@ -292,15 +292,15 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(GlobalObject& globa
|
|||
{
|
||||
// 1. Assert: Type(zonedDateTime) is Object and zonedDateTime has an [[InitializedTemporalZonedDateTime]] internal slot.
|
||||
|
||||
// 2. If increment is not present, set it to 1.
|
||||
// 2. If increment is not present, set increment to 1.
|
||||
if (!increment.has_value())
|
||||
increment = 1;
|
||||
|
||||
// 3. If unit is not present, set it to "nanosecond".
|
||||
// 3. If unit is not present, set unit to "nanosecond".
|
||||
if (!unit.has_value())
|
||||
unit = "nanosecond"sv;
|
||||
|
||||
// 4. If roundingMode is not present, set it to "trunc".
|
||||
// 4. If roundingMode is not present, set roundingMode to "trunc".
|
||||
if (!rounding_mode.has_value())
|
||||
rounding_mode = "trunc"sv;
|
||||
|
||||
|
|
Loading…
Reference in a new issue