mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibJS: Make CreateTemporalDuration return a NonnullGCPtr
Since it can't return null. This also results in a bunch of fallout from callers who were expecting a raw pointer.
This commit is contained in:
parent
fdfe06bb44
commit
6d4eda0028
17 changed files with 52 additions and 52 deletions
|
@ -173,7 +173,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_add)
|
||||||
auto* date = TRY(to_temporal_date(vm, vm.argument(0)));
|
auto* date = TRY(to_temporal_date(vm, vm.argument(0)));
|
||||||
|
|
||||||
// 5. Set duration to ? ToTemporalDuration(duration).
|
// 5. Set duration to ? ToTemporalDuration(duration).
|
||||||
auto* duration = TRY(to_temporal_duration(vm, vm.argument(1)));
|
auto duration = TRY(to_temporal_duration(vm, vm.argument(1)));
|
||||||
|
|
||||||
// 6. Set options to ? GetOptionsObject(options).
|
// 6. Set options to ? GetOptionsObject(options).
|
||||||
auto const* options = TRY(get_options_object(vm, vm.argument(2)));
|
auto const* options = TRY(get_options_object(vm, vm.argument(2)));
|
||||||
|
|
|
@ -126,12 +126,12 @@ ThrowCompletionOr<TimeDurationRecord> create_time_duration_record(VM& vm, double
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.5.8 ToTemporalDuration ( item ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalduration
|
// 7.5.8 ToTemporalDuration ( item ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalduration
|
||||||
ThrowCompletionOr<Duration*> to_temporal_duration(VM& vm, Value item)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> to_temporal_duration(VM& vm, Value item)
|
||||||
{
|
{
|
||||||
// 1. If Type(item) is Object and item has an [[InitializedTemporalDuration]] internal slot, then
|
// 1. If Type(item) is Object and item has an [[InitializedTemporalDuration]] internal slot, then
|
||||||
if (item.is_object() && is<Duration>(item.as_object())) {
|
if (item.is_object() && is<Duration>(item.as_object())) {
|
||||||
// a. Return item.
|
// a. Return item.
|
||||||
return &static_cast<Duration&>(item.as_object());
|
return static_cast<Duration&>(item.as_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Let result be ? ToTemporalDurationRecord(item).
|
// 2. Let result be ? ToTemporalDurationRecord(item).
|
||||||
|
@ -394,7 +394,7 @@ ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(VM&
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.5.14 CreateTemporalDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalduration
|
// 7.5.14 CreateTemporalDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalduration
|
||||||
ThrowCompletionOr<Duration*> create_temporal_duration(VM& vm, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, FunctionObject const* new_target)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> create_temporal_duration(VM& vm, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, FunctionObject const* new_target)
|
||||||
{
|
{
|
||||||
auto& realm = *vm.current_realm();
|
auto& realm = *vm.current_realm();
|
||||||
|
|
||||||
|
@ -420,11 +420,11 @@ ThrowCompletionOr<Duration*> create_temporal_duration(VM& vm, double years, doub
|
||||||
auto object = TRY(ordinary_create_from_constructor<Duration>(vm, *new_target, &Intrinsics::temporal_duration_prototype, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds));
|
auto object = TRY(ordinary_create_from_constructor<Duration>(vm, *new_target, &Intrinsics::temporal_duration_prototype, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds));
|
||||||
|
|
||||||
// 14. Return object.
|
// 14. Return object.
|
||||||
return object.ptr();
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.5.15 CreateNegatedTemporalDuration ( duration ), https://tc39.es/proposal-temporal/#sec-temporal-createnegatedtemporalduration
|
// 7.5.15 CreateNegatedTemporalDuration ( duration ), https://tc39.es/proposal-temporal/#sec-temporal-createnegatedtemporalduration
|
||||||
Duration* create_negated_temporal_duration(VM& vm, Duration const& duration)
|
NonnullGCPtr<Duration> create_negated_temporal_duration(VM& vm, Duration const& duration)
|
||||||
{
|
{
|
||||||
// 1. Return ! CreateTemporalDuration(-duration.[[Years]], -duration.[[Months]], -duration.[[Weeks]], -duration.[[Days]], -duration.[[Hours]], -duration.[[Minutes]], -duration.[[Seconds]], -duration.[[Milliseconds]], -duration.[[Microseconds]], -duration.[[Nanoseconds]]).
|
// 1. Return ! CreateTemporalDuration(-duration.[[Years]], -duration.[[Months]], -duration.[[Weeks]], -duration.[[Days]], -duration.[[Hours]], -duration.[[Minutes]], -duration.[[Seconds]], -duration.[[Milliseconds]], -duration.[[Microseconds]], -duration.[[Nanoseconds]]).
|
||||||
return MUST(create_temporal_duration(vm, -duration.years(), -duration.months(), -duration.weeks(), -duration.days(), -duration.hours(), -duration.minutes(), -duration.seconds(), -duration.milliseconds(), -duration.microseconds(), -duration.nanoseconds()));
|
return MUST(create_temporal_duration(vm, -duration.years(), -duration.months(), -duration.weeks(), -duration.days(), -duration.hours(), -duration.minutes(), -duration.seconds(), -duration.milliseconds(), -duration.microseconds(), -duration.nanoseconds()));
|
||||||
|
@ -829,13 +829,13 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double
|
||||||
VERIFY(sign != 0);
|
VERIFY(sign != 0);
|
||||||
|
|
||||||
// 4. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
// 4. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 5. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
// 5. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 6. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
// 6. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
auto one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
Object* calendar;
|
Object* calendar;
|
||||||
|
|
||||||
|
@ -1024,13 +1024,13 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
|
||||||
VERIFY(sign != 0);
|
VERIFY(sign != 0);
|
||||||
|
|
||||||
// 5. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
// 5. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 6. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
// 6. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 7. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
// 7. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
auto one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 8. Set relativeTo to ? ToTemporalDate(relativeTo).
|
// 8. Set relativeTo to ? ToTemporalDate(relativeTo).
|
||||||
auto* relative_to = TRY(to_temporal_date(vm, relative_to_value));
|
auto* relative_to = TRY(to_temporal_date(vm, relative_to_value));
|
||||||
|
@ -1273,10 +1273,10 @@ ThrowCompletionOr<DurationRecord> add_duration(VM& vm, double years1, double mon
|
||||||
auto& calendar = relative_to.calendar();
|
auto& calendar = relative_to.calendar();
|
||||||
|
|
||||||
// b. Let dateDuration1 be ! CreateTemporalDuration(y1, mon1, w1, d1, 0, 0, 0, 0, 0, 0).
|
// b. Let dateDuration1 be ! CreateTemporalDuration(y1, mon1, w1, d1, 0, 0, 0, 0, 0, 0).
|
||||||
auto* date_duration1 = MUST(create_temporal_duration(vm, years1, months1, weeks1, days1, 0, 0, 0, 0, 0, 0));
|
auto date_duration1 = MUST(create_temporal_duration(vm, years1, months1, weeks1, days1, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// c. Let dateDuration2 be ! CreateTemporalDuration(y2, mon2, w2, d2, 0, 0, 0, 0, 0, 0).
|
// c. Let dateDuration2 be ! CreateTemporalDuration(y2, mon2, w2, d2, 0, 0, 0, 0, 0, 0).
|
||||||
auto* date_duration2 = MUST(create_temporal_duration(vm, years2, months2, weeks2, days2, 0, 0, 0, 0, 0, 0));
|
auto date_duration2 = MUST(create_temporal_duration(vm, years2, months2, weeks2, days2, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// d. Let dateAdd be ? GetMethod(calendar, "dateAdd").
|
// d. Let dateAdd be ? GetMethod(calendar, "dateAdd").
|
||||||
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd));
|
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd));
|
||||||
|
@ -1470,14 +1470,14 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
VERIFY(plain_relative_to);
|
VERIFY(plain_relative_to);
|
||||||
|
|
||||||
// a. Let yearsDuration be ! CreateTemporalDuration(years, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
// a. Let yearsDuration be ! CreateTemporalDuration(years, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* years_duration = MUST(create_temporal_duration(vm, years, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto years_duration = MUST(create_temporal_duration(vm, years, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// FIXME: b. Let yearsLater be ? AddDate(calendarRec, plainRelativeTo, yearsDuration).
|
// FIXME: b. Let yearsLater be ? AddDate(calendarRec, plainRelativeTo, yearsDuration).
|
||||||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
||||||
auto* years_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_duration, nullptr, date_add));
|
auto* years_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_duration, nullptr, date_add));
|
||||||
|
|
||||||
// c. Let yearsMonthsWeeks be ! CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
|
// c. Let yearsMonthsWeeks be ! CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* years_months_weeks = MUST(create_temporal_duration(vm, years, months, weeks, 0, 0, 0, 0, 0, 0, 0));
|
auto years_months_weeks = MUST(create_temporal_duration(vm, years, months, weeks, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// FIXME: d. Let yearsMonthsWeeksLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonthsWeeks).
|
// FIXME: d. Let yearsMonthsWeeksLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonthsWeeks).
|
||||||
auto* years_months_weeks_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months_weeks, nullptr, date_add));
|
auto* years_months_weeks_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months_weeks, nullptr, date_add));
|
||||||
|
@ -1534,7 +1534,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
auto sign = fractional_days < 0 ? -1 : 1;
|
auto sign = fractional_days < 0 ? -1 : 1;
|
||||||
|
|
||||||
// u. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
// u. Let oneYear be ! CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_year = MUST(create_temporal_duration(vm, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// v. Set moveResult to ? MoveRelativeDate(calendarRec, plainRelativeTo, oneYear).
|
// v. Set moveResult to ? MoveRelativeDate(calendarRec, plainRelativeTo, oneYear).
|
||||||
// FIXME:: pass through calendarRec
|
// FIXME:: pass through calendarRec
|
||||||
|
@ -1565,14 +1565,14 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
VERIFY(plain_relative_to);
|
VERIFY(plain_relative_to);
|
||||||
|
|
||||||
// a. Let yearsMonths be ! CreateTemporalDuration(years, months, 0, 0, 0, 0, 0, 0, 0, 0).
|
// a. Let yearsMonths be ! CreateTemporalDuration(years, months, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* years_months = MUST(create_temporal_duration(vm, years, months, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto years_months = MUST(create_temporal_duration(vm, years, months, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// FIXME: b. Let yearsMonthsLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonths).
|
// FIXME: b. Let yearsMonthsLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonths).
|
||||||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
||||||
auto* years_months_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months, nullptr, date_add));
|
auto* years_months_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months, nullptr, date_add));
|
||||||
|
|
||||||
// c. Let yearsMonthsWeeks be ! CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
|
// c. Let yearsMonthsWeeks be ! CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* years_months_weeks = MUST(create_temporal_duration(vm, years, months, weeks, 0, 0, 0, 0, 0, 0, 0));
|
auto years_months_weeks = MUST(create_temporal_duration(vm, years, months, weeks, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// FIXME: d. Let yearsMonthsWeeksLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonthsWeeks).
|
// FIXME: d. Let yearsMonthsWeeksLater be ? AddDate(calendarRec, plainRelativeTo, yearsMonthsWeeks).
|
||||||
auto* years_months_weeks_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months_weeks, nullptr, date_add));
|
auto* years_months_weeks_later = TRY(calendar_date_add(vm, *calendar, plain_relative_to, *years_months_weeks, nullptr, date_add));
|
||||||
|
@ -1610,7 +1610,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
months += months_passed;
|
months += months_passed;
|
||||||
|
|
||||||
// o. Let monthsPassedDuration be ! CreateTemporalDuration(0, monthsPassed, 0, 0, 0, 0, 0, 0, 0, 0).
|
// o. Let monthsPassedDuration be ! CreateTemporalDuration(0, monthsPassed, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* months_passed_duration = MUST(create_temporal_duration(vm, 0, months_passed, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto months_passed_duration = MUST(create_temporal_duration(vm, 0, months_passed, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// p. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, monthsPassedDuration).
|
// p. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, monthsPassedDuration).
|
||||||
// FIXME: Pass through calendarRec
|
// FIXME: Pass through calendarRec
|
||||||
|
@ -1629,7 +1629,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
auto sign = fractional_days < 0 ? -1 : 1;
|
auto sign = fractional_days < 0 ? -1 : 1;
|
||||||
|
|
||||||
// u. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
// u. Let oneMonth be ! CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
auto one_month = MUST(create_temporal_duration(vm, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// v. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, oneMonth).
|
// v. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, oneMonth).
|
||||||
// FIXME: spec bug, this should be set.
|
// FIXME: spec bug, this should be set.
|
||||||
|
@ -1682,7 +1682,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
weeks += weeks_passed;
|
weeks += weeks_passed;
|
||||||
|
|
||||||
// h. Let weeksPassedDuration be ! CreateTemporalDuration(0, 0, weeksPassed, 0, 0, 0, 0, 0, 0, 0).
|
// h. Let weeksPassedDuration be ! CreateTemporalDuration(0, 0, weeksPassed, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* weeks_passed_duration = MUST(create_temporal_duration(vm, 0, 0, weeks_passed, 0, 0, 0, 0, 0, 0, 0));
|
auto weeks_passed_duration = MUST(create_temporal_duration(vm, 0, 0, weeks_passed, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// FIXME: i. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, weeksPassedDuration).
|
// FIXME: i. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, weeksPassedDuration).
|
||||||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd));
|
||||||
|
@ -1701,7 +1701,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
||||||
auto sign = fractional_days < 0 ? -1 : 1;
|
auto sign = fractional_days < 0 ? -1 : 1;
|
||||||
|
|
||||||
// n. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
// n. Let oneWeek be ! CreateTemporalDuration(0, 0, sign, 0, 0, 0, 0, 0, 0, 0).
|
||||||
auto* one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
auto one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// o. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, oneWeek).
|
// o. Let moveResult be ? MoveRelativeDate(calendarRec, plainRelativeTo, oneWeek).
|
||||||
// FIXME: spec bug, should be set
|
// FIXME: spec bug, should be set
|
||||||
|
@ -2019,7 +2019,7 @@ ThrowCompletionOr<String> temporal_duration_to_string(VM& vm, double years, doub
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.5.28 AddDurationToOrSubtractDurationFromDuration ( operation, duration, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-adddurationtoorsubtractdurationfromduration
|
// 7.5.28 AddDurationToOrSubtractDurationFromDuration ( operation, duration, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-adddurationtoorsubtractdurationfromduration
|
||||||
ThrowCompletionOr<Duration*> add_duration_to_or_subtract_duration_from_duration(VM& vm, ArithmeticOperation operation, Duration const& duration, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> add_duration_to_or_subtract_duration_from_duration(VM& vm, ArithmeticOperation operation, Duration const& duration, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is subtract, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is subtract, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == ArithmeticOperation::Subtract ? -1 : 1;
|
i8 sign = operation == ArithmeticOperation::Subtract ? -1 : 1;
|
||||||
|
|
|
@ -123,14 +123,14 @@ ThrowCompletionOr<DurationRecord> create_duration_record(VM&, double years, doub
|
||||||
DateDurationRecord create_date_duration_record(double years, double months, double weeks, double days);
|
DateDurationRecord create_date_duration_record(double years, double months, double weeks, double days);
|
||||||
ThrowCompletionOr<DateDurationRecord> create_date_duration_record(VM&, double years, double months, double weeks, double days);
|
ThrowCompletionOr<DateDurationRecord> create_date_duration_record(VM&, double years, double months, double weeks, double days);
|
||||||
ThrowCompletionOr<TimeDurationRecord> create_time_duration_record(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
ThrowCompletionOr<TimeDurationRecord> create_time_duration_record(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||||
ThrowCompletionOr<Duration*> to_temporal_duration(VM&, Value item);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> to_temporal_duration(VM&, Value item);
|
||||||
ThrowCompletionOr<DurationRecord> to_temporal_duration_record(VM&, Value temporal_duration_like);
|
ThrowCompletionOr<DurationRecord> to_temporal_duration_record(VM&, Value temporal_duration_like);
|
||||||
i8 duration_sign(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
i8 duration_sign(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||||
bool is_valid_duration(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
bool is_valid_duration(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||||
StringView default_temporal_largest_unit(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds);
|
StringView default_temporal_largest_unit(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds);
|
||||||
ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(VM&, Value temporal_duration_like);
|
ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(VM&, Value temporal_duration_like);
|
||||||
ThrowCompletionOr<Duration*> create_temporal_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, FunctionObject const* new_target = nullptr);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> create_temporal_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, FunctionObject const* new_target = nullptr);
|
||||||
Duration* create_negated_temporal_duration(VM&, Duration const& duration);
|
NonnullGCPtr<Duration> create_negated_temporal_duration(VM&, Duration const& duration);
|
||||||
ThrowCompletionOr<double> calculate_offset_shift(VM&, Value relative_to_value, double years, double months, double weeks, double days);
|
ThrowCompletionOr<double> calculate_offset_shift(VM&, Value relative_to_value, double years, double months, double weeks, double days);
|
||||||
Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, double offset_shift);
|
Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, double offset_shift);
|
||||||
ThrowCompletionOr<TimeDurationRecord> balance_time_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, StringView largest_unit);
|
ThrowCompletionOr<TimeDurationRecord> balance_time_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, StringView largest_unit);
|
||||||
|
@ -151,7 +151,7 @@ ThrowCompletionOr<ZonedDateTime*> move_relative_zoned_date_time(VM&, ZonedDateTi
|
||||||
ThrowCompletionOr<RoundedDuration> round_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object = nullptr);
|
ThrowCompletionOr<RoundedDuration> round_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object = nullptr);
|
||||||
ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object);
|
ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object);
|
||||||
ThrowCompletionOr<String> temporal_duration_to_string(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision);
|
ThrowCompletionOr<String> temporal_duration_to_string(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision);
|
||||||
ThrowCompletionOr<Duration*> add_duration_to_or_subtract_duration_from_duration(VM&, ArithmeticOperation, Duration const&, Value other_value, Value options_value);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> add_duration_to_or_subtract_duration_from_duration(VM&, ArithmeticOperation, Duration const&, Value other_value, Value options_value);
|
||||||
|
|
||||||
// 7.5.22 DaysUntil ( earlier, later ), https://tc39.es/proposal-temporal/#sec-temporal-daysuntil
|
// 7.5.22 DaysUntil ( earlier, later ), https://tc39.es/proposal-temporal/#sec-temporal-daysuntil
|
||||||
template<typename EarlierObjectType, typename LaterObjectType>
|
template<typename EarlierObjectType, typename LaterObjectType>
|
||||||
|
|
|
@ -84,7 +84,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DurationConstructor::construct(FunctionO
|
||||||
auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
|
auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
|
||||||
|
|
||||||
// 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).
|
// 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).
|
||||||
return *TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
|
return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.2.2 Temporal.Duration.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.duration.from
|
// 7.2.2 Temporal.Duration.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.duration.from
|
||||||
|
@ -108,10 +108,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationConstructor::from)
|
||||||
JS_DEFINE_NATIVE_FUNCTION(DurationConstructor::compare)
|
JS_DEFINE_NATIVE_FUNCTION(DurationConstructor::compare)
|
||||||
{
|
{
|
||||||
// 1. Set one to ? ToTemporalDuration(one).
|
// 1. Set one to ? ToTemporalDuration(one).
|
||||||
auto* one = TRY(to_temporal_duration(vm, vm.argument(0)));
|
auto one = TRY(to_temporal_duration(vm, vm.argument(0)));
|
||||||
|
|
||||||
// 2. Set two to ? ToTemporalDuration(two).
|
// 2. Set two to ? ToTemporalDuration(two).
|
||||||
auto* two = TRY(to_temporal_duration(vm, vm.argument(1)));
|
auto two = TRY(to_temporal_duration(vm, vm.argument(1)));
|
||||||
|
|
||||||
// 3. Set options to ? GetOptionsObject(options).
|
// 3. Set options to ? GetOptionsObject(options).
|
||||||
auto const* options = TRY(get_options_object(vm, vm.argument(2)));
|
auto const* options = TRY(get_options_object(vm, vm.argument(2)));
|
||||||
|
|
|
@ -312,7 +312,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8.5.9 DifferenceTemporalInstant ( operation, instant, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalinstant
|
// 8.5.9 DifferenceTemporalInstant ( operation, instant, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalinstant
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_instant(VM& vm, DifferenceOperation operation, Instant const& instant, Value other_value, Value options)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_instant(VM& vm, DifferenceOperation operation, Instant const& instant, Value other_value, Value options)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
|
|
@ -52,7 +52,7 @@ ThrowCompletionOr<BigInt*> add_instant(VM&, BigInt const& epoch_nanoseconds, dou
|
||||||
TimeDurationRecord difference_instant(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, u64 rounding_increment, StringView smallest_unit, StringView largest_unit, StringView rounding_mode);
|
TimeDurationRecord difference_instant(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, u64 rounding_increment, StringView smallest_unit, StringView largest_unit, StringView rounding_mode);
|
||||||
BigInt* round_temporal_instant(VM&, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode);
|
BigInt* round_temporal_instant(VM&, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode);
|
||||||
ThrowCompletionOr<String> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
ThrowCompletionOr<String> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_instant(VM&, DifferenceOperation, Instant const&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_instant(VM&, DifferenceOperation, Instant const&, Value other, Value options);
|
||||||
ThrowCompletionOr<Instant*> add_duration_to_or_subtract_duration_from_instant(VM&, ArithmeticOperation, Instant const&, Value temporal_duration_like);
|
ThrowCompletionOr<Instant*> add_duration_to_or_subtract_duration_from_instant(VM&, ArithmeticOperation, Instant const&, Value temporal_duration_like);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ ThrowCompletionOr<NonnullGCPtr<Duration>> difference_date(VM& vm, Object const&
|
||||||
// 5. If one.[[ISOYear]] = two.[[ISOYear]] and one.[[ISOMonth]] = two.[[ISOMonth]] and one.[[ISODay]] = two.[[ISODay]], then
|
// 5. If one.[[ISOYear]] = two.[[ISOYear]] and one.[[ISOMonth]] = two.[[ISOMonth]] and one.[[ISODay]] = two.[[ISODay]], then
|
||||||
if (one.iso_year() == two.iso_year() && one.iso_month() == two.iso_month() && one.iso_day() == two.iso_day()) {
|
if (one.iso_year() == two.iso_year() && one.iso_month() == two.iso_month() && one.iso_day() == two.iso_day()) {
|
||||||
// a. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
// a. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
|
||||||
return *MUST(create_temporal_duration(vm, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
return MUST(create_temporal_duration(vm, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. If ! Get(options, "largestUnit") is "day", then
|
// 6. If ! Get(options, "largestUnit") is "day", then
|
||||||
|
@ -406,7 +406,7 @@ ThrowCompletionOr<NonnullGCPtr<Duration>> difference_date(VM& vm, Object const&
|
||||||
auto days = days_until(one, two);
|
auto days = days_until(one, two);
|
||||||
|
|
||||||
// b. Return ! CreateTemporalDuration(0, 0, 0, days, 0, 0, 0, 0, 0, 0).
|
// b. Return ! CreateTemporalDuration(0, 0, 0, days, 0, 0, 0, 0, 0, 0).
|
||||||
return *MUST(create_temporal_duration(vm, 0, 0, 0, days, 0, 0, 0, 0, 0, 0));
|
return MUST(create_temporal_duration(vm, 0, 0, 0, days, 0, 0, 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Return ? CalendarDateUntil(calendarRec, one, two, options).
|
// 7. Return ? CalendarDateUntil(calendarRec, one, two, options).
|
||||||
|
@ -529,7 +529,7 @@ i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.5.11 DifferenceTemporalPlainDate ( operation, temporalDate, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaindate
|
// 3.5.11 DifferenceTemporalPlainDate ( operation, temporalDate, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaindate
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date(VM& vm, DifferenceOperation operation, PlainDate& temporal_date, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_date(VM& vm, DifferenceOperation operation, PlainDate& temporal_date, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
|
|
@ -58,7 +58,7 @@ ThrowCompletionOr<String> pad_iso_year(VM&, i32 y);
|
||||||
ThrowCompletionOr<String> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
ThrowCompletionOr<String> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
||||||
ThrowCompletionOr<ISODateRecord> add_iso_date(VM&, i32 year, u8 month, u8 day, double years, double months, double weeks, double days, StringView overflow);
|
ThrowCompletionOr<ISODateRecord> add_iso_date(VM&, i32 year, u8 month, u8 day, double years, double months, double weeks, double days, StringView overflow);
|
||||||
i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2);
|
i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2);
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date(VM&, DifferenceOperation, PlainDate&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_date(VM&, DifferenceOperation, PlainDate&, Value other, Value options);
|
||||||
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_date(VM& vm, Object const& calendar, PlainDate const& one, PlainDate const& two, Object const& options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_date(VM& vm, Object const& calendar, PlainDate const& one, PlainDate const& two, Object const& options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::add)
|
||||||
auto temporal_date = TRY(typed_this_object(vm));
|
auto temporal_date = TRY(typed_this_object(vm));
|
||||||
|
|
||||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||||
auto* duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
auto duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
||||||
|
|
||||||
// 4. Set options to ? GetOptionsObject(options).
|
// 4. Set options to ? GetOptionsObject(options).
|
||||||
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||||
|
@ -386,13 +386,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::subtract)
|
||||||
auto temporal_date = TRY(typed_this_object(vm));
|
auto temporal_date = TRY(typed_this_object(vm));
|
||||||
|
|
||||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||||
auto* duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
auto duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
||||||
|
|
||||||
// 4. Set options to ? GetOptionsObject(options).
|
// 4. Set options to ? GetOptionsObject(options).
|
||||||
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||||
|
|
||||||
// 5. Let negatedDuration be ! CreateNegatedTemporalDuration(duration).
|
// 5. Let negatedDuration be ! CreateNegatedTemporalDuration(duration).
|
||||||
auto* negated_duration = create_negated_temporal_duration(vm, *duration);
|
auto negated_duration = create_negated_temporal_duration(vm, *duration);
|
||||||
|
|
||||||
// 6. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate, negatedDuration, options).
|
// 6. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate, negatedDuration, options).
|
||||||
return TRY(calendar_date_add(vm, temporal_date->calendar(), temporal_date, *negated_duration, options));
|
return TRY(calendar_date_add(vm, temporal_date->calendar(), temporal_date, *negated_duration, options));
|
||||||
|
|
|
@ -300,7 +300,7 @@ ThrowCompletionOr<TemporalPlainDateTime> add_date_time(VM& vm, i32 year, u8 mont
|
||||||
auto* date_part = MUST(create_temporal_date(vm, year, month, day, calendar));
|
auto* date_part = MUST(create_temporal_date(vm, year, month, day, calendar));
|
||||||
|
|
||||||
// 4. Let dateDuration be ? CreateTemporalDuration(years, months, weeks, days + timeResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
// 4. Let dateDuration be ? CreateTemporalDuration(years, months, weeks, days + timeResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
||||||
auto* date_duration = TRY(create_temporal_duration(vm, years, months, weeks, days + time_result.days, 0, 0, 0, 0, 0, 0));
|
auto date_duration = TRY(create_temporal_duration(vm, years, months, weeks, days + time_result.days, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 5. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
|
// 5. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
|
||||||
auto* added_date = TRY(calendar_date_add(vm, calendar, date_part, *date_duration, options));
|
auto* added_date = TRY(calendar_date_add(vm, calendar, date_part, *date_duration, options));
|
||||||
|
@ -384,7 +384,7 @@ ThrowCompletionOr<DurationRecord> difference_iso_date_time(VM& vm, i32 year1, u8
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.5.11 DifferenceTemporalPlainDateTime ( operation, dateTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaindatetime
|
// 5.5.11 DifferenceTemporalPlainDateTime ( operation, dateTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaindatetime
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date_time(VM& vm, DifferenceOperation operation, PlainDateTime& date_time, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_date_time(VM& vm, DifferenceOperation operation, PlainDateTime& date_time, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
|
|
@ -75,7 +75,7 @@ i8 compare_iso_date_time(i32 year1, u8 month1, u8 day1, u8 hour1, u8 minute1, u8
|
||||||
ThrowCompletionOr<TemporalPlainDateTime> add_date_time(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options);
|
ThrowCompletionOr<TemporalPlainDateTime> add_date_time(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options);
|
||||||
ISODateTime round_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length = {});
|
ISODateTime round_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length = {});
|
||||||
ThrowCompletionOr<DurationRecord> difference_iso_date_time(VM&, i32 year1, u8 month1, u8 day1, u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, i32 year2, u8 month2, u8 day2, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2, Object& calendar, StringView largest_unit, Object const& options);
|
ThrowCompletionOr<DurationRecord> difference_iso_date_time(VM&, i32 year1, u8 month1, u8 day1, u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, i32 year2, u8 month2, u8 day2, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2, Object& calendar, StringView largest_unit, Object const& options);
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date_time(VM&, DifferenceOperation, PlainDateTime&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_date_time(VM&, DifferenceOperation, PlainDateTime&, Value other, Value options);
|
||||||
ThrowCompletionOr<PlainDateTime*> add_duration_to_or_subtract_duration_from_plain_date_time(VM&, ArithmeticOperation, PlainDateTime&, Value temporal_duration_like, Value options_value);
|
ThrowCompletionOr<PlainDateTime*> add_duration_to_or_subtract_duration_from_plain_date_time(VM&, ArithmeticOperation, PlainDateTime&, Value temporal_duration_like, Value options_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,7 +644,7 @@ DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 micro
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.13 DifferenceTemporalPlainTime ( operation, temporalTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaintime
|
// 4.5.13 DifferenceTemporalPlainTime ( operation, temporalTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplaintime
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_time(VM& vm, DifferenceOperation operation, PlainTime const& temporal_time, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_time(VM& vm, DifferenceOperation operation, PlainTime const& temporal_time, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
|
|
@ -90,7 +90,7 @@ ThrowCompletionOr<String> temporal_time_to_string(VM&, u8 hour, u8 minute, u8 se
|
||||||
i8 compare_temporal_time(u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2);
|
i8 compare_temporal_time(u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2);
|
||||||
DaysAndTime add_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
DaysAndTime add_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||||
DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {});
|
DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {});
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_time(VM&, DifferenceOperation, PlainTime const&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_time(VM&, DifferenceOperation, PlainTime const&, Value other, Value options);
|
||||||
ThrowCompletionOr<PlainTime*> add_duration_to_or_subtract_duration_from_plain_time(VM&, ArithmeticOperation, PlainTime const&, Value temporal_duration_like);
|
ThrowCompletionOr<PlainTime*> add_duration_to_or_subtract_duration_from_plain_time(VM&, ArithmeticOperation, PlainTime const&, Value temporal_duration_like);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth&
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.5.7 DifferenceTemporalPlainYearMonth ( operation, yearMonth, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplainyearmonth
|
// 9.5.7 DifferenceTemporalPlainYearMonth ( operation, yearMonth, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplainyearmonth
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_year_month(VM& vm, DifferenceOperation operation, PlainYearMonth& year_month, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_year_month(VM& vm, DifferenceOperation operation, PlainYearMonth& year_month, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
@ -317,7 +317,7 @@ ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_pla
|
||||||
auto& realm = *vm.current_realm();
|
auto& realm = *vm.current_realm();
|
||||||
|
|
||||||
// 1. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
// 1. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||||
auto* duration = TRY(to_temporal_duration(vm, temporal_duration_like));
|
auto duration = TRY(to_temporal_duration(vm, temporal_duration_like));
|
||||||
|
|
||||||
// 2. If operation is subtract, then
|
// 2. If operation is subtract, then
|
||||||
if (operation == ArithmeticOperation::Subtract) {
|
if (operation == ArithmeticOperation::Subtract) {
|
||||||
|
@ -363,7 +363,7 @@ ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_pla
|
||||||
auto* date = TRY(calendar_date_from_fields(vm, calendar, *fields));
|
auto* date = TRY(calendar_date_from_fields(vm, calendar, *fields));
|
||||||
|
|
||||||
// 13. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
// 13. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
||||||
auto* duration_to_add = MUST(create_temporal_duration(vm, duration->years(), duration->months(), duration->weeks(), balance_result.days, 0, 0, 0, 0, 0, 0));
|
auto duration_to_add = MUST(create_temporal_duration(vm, duration->years(), duration->months(), duration->weeks(), balance_result.days, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 14. Let optionsCopy be OrdinaryObjectCreate(null).
|
// 14. Let optionsCopy be OrdinaryObjectCreate(null).
|
||||||
auto options_copy = Object::create(realm, nullptr);
|
auto options_copy = Object::create(realm, nullptr);
|
||||||
|
|
|
@ -48,7 +48,7 @@ bool iso_year_month_within_limits(i32 year, u8 month);
|
||||||
ISOYearMonth balance_iso_year_month(double year, double month);
|
ISOYearMonth balance_iso_year_month(double year, double month);
|
||||||
ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr);
|
ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr);
|
||||||
ThrowCompletionOr<String> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar);
|
ThrowCompletionOr<String> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar);
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_plain_year_month(VM&, DifferenceOperation, PlainYearMonth&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_plain_year_month(VM&, DifferenceOperation, PlainYearMonth&, Value other, Value options);
|
||||||
ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_plain_year_month(VM&, ArithmeticOperation, PlainYearMonth&, Value temporal_duration_like, Value options_value);
|
ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_plain_year_month(VM&, ArithmeticOperation, PlainYearMonth&, Value temporal_duration_like, Value options_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ ThrowCompletionOr<BigInt*> add_zoned_date_time(VM& vm, BigInt const& epoch_nanos
|
||||||
auto* date_part = MUST(create_temporal_date(vm, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), calendar));
|
auto* date_part = MUST(create_temporal_date(vm, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), calendar));
|
||||||
|
|
||||||
// 7. Let dateDuration be ! CreateTemporalDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0).
|
// 7. Let dateDuration be ! CreateTemporalDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0).
|
||||||
auto* date_duration = MUST(create_temporal_duration(vm, years, months, weeks, days, 0, 0, 0, 0, 0, 0));
|
auto date_duration = MUST(create_temporal_duration(vm, years, months, weeks, days, 0, 0, 0, 0, 0, 0));
|
||||||
|
|
||||||
// 8. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
|
// 8. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
|
||||||
auto* added_date = TRY(calendar_date_add(vm, calendar, date_part, *date_duration, options));
|
auto* added_date = TRY(calendar_date_add(vm, calendar, date_part, *date_duration, options));
|
||||||
|
@ -571,7 +571,7 @@ ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM& vm, Crypto::S
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.5.8 DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalzoneddatetime
|
// 6.5.8 DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalzoneddatetime
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_zoned_date_time(VM& vm, DifferenceOperation operation, ZonedDateTime& zoned_date_time, Value other_value, Value options_value)
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_zoned_date_time(VM& vm, DifferenceOperation operation, ZonedDateTime& zoned_date_time, Value other_value, Value options_value)
|
||||||
{
|
{
|
||||||
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
// 1. If operation is since, let sign be -1. Otherwise, let sign be 1.
|
||||||
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
i8 sign = operation == DifferenceOperation::Since ? -1 : 1;
|
||||||
|
|
|
@ -60,7 +60,7 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM&, ZonedDateTime&
|
||||||
ThrowCompletionOr<BigInt*> add_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Value time_zone, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options = nullptr);
|
ThrowCompletionOr<BigInt*> add_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Value time_zone, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options = nullptr);
|
||||||
ThrowCompletionOr<DurationRecord> difference_zoned_date_time(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, Object& time_zone, Object& calendar, StringView largest_unit, Object const& options);
|
ThrowCompletionOr<DurationRecord> difference_zoned_date_time(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, Object& time_zone, Object& calendar, StringView largest_unit, Object const& options);
|
||||||
ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM&, Crypto::SignedBigInteger nanoseconds, Value relative_to);
|
ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM&, Crypto::SignedBigInteger nanoseconds, Value relative_to);
|
||||||
ThrowCompletionOr<Duration*> difference_temporal_zoned_date_time(VM&, DifferenceOperation, ZonedDateTime&, Value other, Value options);
|
ThrowCompletionOr<NonnullGCPtr<Duration>> difference_temporal_zoned_date_time(VM&, DifferenceOperation, ZonedDateTime&, Value other, Value options);
|
||||||
ThrowCompletionOr<ZonedDateTime*> add_duration_to_or_subtract_duration_from_zoned_date_time(VM&, ArithmeticOperation, ZonedDateTime&, Value temporal_duration_like, Value options_value);
|
ThrowCompletionOr<ZonedDateTime*> add_duration_to_or_subtract_duration_from_zoned_date_time(VM&, ArithmeticOperation, ZonedDateTime&, Value temporal_duration_like, Value options_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue