summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp18
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp106
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Duration.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp16
4 files changed, 65 insertions, 79 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index 14df4ebd6d..225e049386 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -587,18 +587,18 @@ ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject& global_object
if (value.is_object()) {
auto& value_object = value.as_object();
- // a. If value has either an [[InitializedTemporalDateTime]] or [[InitializedTemporalZonedDateTime]] internal slot, then
- if (is<PlainDateTime>(value_object) || is<ZonedDateTime>(value_object)) {
+ // a. If value has either an [[InitializedTemporalDate]] or [[InitializedTemporalZonedDateTime]] internal slot, then
+ if (is<PlainDate>(value_object) || is<ZonedDateTime>(value_object)) {
// i. Return value.
return value;
}
- // b. If value has an [[InitializedTemporalDate]] internal slot, then
- if (is<PlainDate>(value_object)) {
- auto& plain_date_object = static_cast<PlainDate&>(value_object);
+ // b. If value has an [[InitializedTemporalDateTime]] internal slot, then
+ if (is<PlainDateTime>(value_object)) {
+ auto& plain_date_time = static_cast<PlainDateTime&>(value_object);
- // i. Return ? CreateTemporalDateTime(value.[[ISOYear]], value.[[ISOMonth]], value.[[ISODay]], 0, 0, 0, 0, 0, 0, value.[[Calendar]]).
- return TRY(create_temporal_date_time(global_object, plain_date_object.iso_year(), plain_date_object.iso_month(), plain_date_object.iso_day(), 0, 0, 0, 0, 0, 0, plain_date_object.calendar()));
+ // i. Return ? CreateTemporalDate(value.[[ISOYear]], value.[[ISOMonth]], value.[[ISODay]], 0, 0, 0, 0, 0, 0, value.[[Calendar]]).
+ return TRY(create_temporal_date(global_object, plain_date_time.iso_year(), plain_date_time.iso_month(), plain_date_time.iso_day(), plain_date_time.calendar()));
}
// c. Let calendar be ? GetTemporalCalendarWithISODefault(value).
@@ -698,8 +698,8 @@ ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject& global_object
return MUST(create_temporal_zoned_date_time(global_object, *epoch_nanoseconds, time_zone.as_object(), *calendar));
}
- // 9. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).
- return TRY(create_temporal_date_time(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, *calendar));
+ // 9. Return ! CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
+ return TRY(create_temporal_date(global_object, result.year, result.month, result.day, *calendar));
}
// 13.22 ValidateTemporalUnitRange ( largestUnit, smallestUnit ), https://tc39.es/proposal-temporal/#sec-temporal-validatetemporalunitrange
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
index 55e542d86c..509c94b069 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
@@ -487,12 +487,12 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// 7. If relativeTo is not undefined, then
if (!relative_to.is_undefined()) {
- // a. Set relativeTo to ? ToTemporalDateTime(relativeTo).
- PlainDateTime* relative_to_plain_date_time = TRY(to_temporal_date_time(global_object, relative_to));
- relative_to = relative_to_plain_date_time;
+ // a. Set relativeTo to ? ToTemporalDate(relativeTo).
+ auto* relative_to_plain_date = TRY(to_temporal_date(global_object, relative_to));
+ relative_to = relative_to_plain_date;
// b. Let calendar be relativeTo.[[Calendar]].
- calendar = &relative_to_plain_date_time->calendar();
+ calendar = &relative_to_plain_date->calendar();
}
// 8. Else,
else {
@@ -555,7 +555,7 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// b. Repeat, while years ≠ 0,
while (years != 0) {
// i. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneYear).
- auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDateTime>(relative_to.as_object()), *one_year));
+ auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDate>(relative_to.as_object()), *one_year));
// ii. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
@@ -570,7 +570,7 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// c. Repeat, while months ≠ 0,
while (months != 0) {
// i. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneMonth).
- auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDateTime>(relative_to.as_object()), *one_month));
+ auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDate>(relative_to.as_object()), *one_month));
// ii. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
@@ -595,7 +595,7 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// ii. Repeat, while years ≠ 0,
while (years != 0) {
// 1. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneYear).
- auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDateTime>(relative_to.as_object()), *one_year));
+ auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDate>(relative_to.as_object()), *one_year));
// 2. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
@@ -610,7 +610,7 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// iii. Repeat, while months ≠ 0,
while (months != 0) {
// 1. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneMonth).
- auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDateTime>(relative_to.as_object()), *one_month));
+ auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDate>(relative_to.as_object()), *one_month));
// 2. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
@@ -625,7 +625,7 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
// iv. Repeat, while weeks ≠ 0,
while (weeks != 0) {
// 1. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneWeek).
- auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDateTime>(relative_to.as_object()), *one_week));
+ auto move_result = TRY(move_relative_date(global_object, *calendar, verify_cast<PlainDate>(relative_to.as_object()), *one_week));
// 2. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
@@ -644,25 +644,22 @@ ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&
}
// 7.5.16 MoveRelativeDate ( calendar, relativeTo, duration ), https://tc39.es/proposal-temporal/#sec-temporal-moverelativedate
-ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(GlobalObject& global_object, Object& calendar, PlainDateTime& relative_to, Duration& duration)
+ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(GlobalObject& global_object, Object& calendar, PlainDate& relative_to, Duration& duration)
{
// 1. Assert: Type(relativeTo) is Object.
- // 2. Assert: relativeTo has an [[InitializedTemporalDateTime]] internal slot.
+ // 2. Assert: relativeTo has an [[InitializedTemporalDate]] internal slot.
// 3. Let options be ! OrdinaryObjectCreate(null).
auto* options = Object::create(global_object, nullptr);
- // 4. Let later be ? CalendarDateAdd(calendar, relativeTo, duration, options).
- auto* later = TRY(calendar_date_add(global_object, calendar, &relative_to, duration, options));
+ // 4. Let newDate be ? CalendarDateAdd(calendar, relativeTo, duration, options).
+ auto* new_date = TRY(calendar_date_add(global_object, calendar, &relative_to, duration, options));
- // 5. Let days be ? DaysUntil(relativeTo, later).
- auto days = days_until(global_object, relative_to, *later);
+ // 5. Let days be ! DaysUntil(relativeTo, newDate).
+ auto days = days_until(global_object, relative_to, *new_date);
- // 6. Let dateTime be ? CreateTemporalDateTime(later.[[ISOYear]], later.[[ISOMonth]], later.[[ISODay]], relativeTo.[[ISOHour]], relativeTo.[[ISOMinute]], relativeTo.[[ISOSecond]], relativeTo.[[ISOMillisecond]], relativeTo.[[ISOMicrosecond]], relativeTo.[[ISONanosecond]], relativeTo.[[Calendar]]).
- auto* date_time = TRY(create_temporal_date_time(global_object, later->iso_year(), later->iso_month(), later->iso_day(), relative_to.iso_hour(), relative_to.iso_minute(), relative_to.iso_second(), relative_to.iso_millisecond(), relative_to.iso_microsecond(), relative_to.iso_nanosecond(), relative_to.calendar()));
-
- // 7. Return the Record { [[RelativeTo]]: dateTime, [[Days]]: days }.
- return MoveRelativeDateResult { .relative_to = make_handle(date_time), .days = days };
+ // 6. Return the Record { [[RelativeTo]]: newDate, [[Days]]: days }.
+ return MoveRelativeDateResult { .relative_to = make_handle(new_date), .days = days };
}
// 7.5.17 MoveRelativeZonedDateTime ( zonedDateTime, years, months, weeks, days ), https://tc39.es/proposal-temporal/#sec-temporal-moverelativezoneddatetime
@@ -684,11 +681,9 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
double fractional_seconds = 0;
// 1. If relativeTo is not present, set relativeTo to undefined.
- // NOTE: `relative_to_object`, `relative_to_date`, and `relative_to` in the various code paths below
- // are all the same as far as the spec is concerned, but the latter two are more strictly typed for convenience.
- // The `_date` suffix is used as relativeTo is guaranteed to be a PlainDateTime object or undefined after step 5
- // (i.e. PlainDateTime*), but a PlainDate object is assigned in a couple of cases.
- PlainDateTime* relative_to = nullptr;
+ // NOTE: `relative_to_object` and `relative_to` in the various code paths below are all the same as far as the
+ // spec is concerned, but the latter is more strictly typed for convenience.
+ PlainDate* relative_to = nullptr;
// 2. Let years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, and increment each be the mathematical values of themselves.
@@ -716,15 +711,18 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
// ii. Set zonedRelativeTo to relativeTo.
zoned_relative_to = relative_to_zoned_date_time;
- // iii. Set relativeTo to ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], instant, relativeTo.[[Calendar]]).
- relative_to = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &relative_to_zoned_date_time->time_zone(), *instant, relative_to_zoned_date_time->calendar()));
+ // iii. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], instant, relativeTo.[[Calendar]]).
+ auto* plain_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &relative_to_zoned_date_time->time_zone(), *instant, relative_to_zoned_date_time->calendar()));
+
+ // iv. Set relativeTo to ! CreateTemporalDate(plainDateTime.[[ISOYear]], plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], relativeTo.[[Calendar]]).
+ relative_to = TRY(create_temporal_date(global_object, plain_date_time->iso_year(), plain_date_time->iso_month(), plain_date_time->iso_day(), relative_to_zoned_date_time->calendar()));
}
// b. Else,
else {
- // i. Assert: relativeTo has an [[InitializedTemporalDateTime]] internal slot.
- VERIFY(is<PlainDateTime>(relative_to_object));
+ // i. Assert: relativeTo has an [[InitializedTemporalDate]] internal slot.
+ VERIFY(is<PlainDate>(relative_to_object));
- relative_to = static_cast<PlainDateTime*>(relative_to_object);
+ relative_to = static_cast<PlainDate*>(relative_to_object);
}
// c. Let calendar be relativeTo.[[Calendar]].
@@ -800,7 +798,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto months_weeks_in_days = days_until(global_object, *years_later, *years_months_weeks_later);
// i. Set relativeTo to yearsLater.
- auto* relative_to_date = years_later;
+ relative_to = years_later;
// j. Let days be days + monthsWeeksInDays.
days += months_weeks_in_days;
@@ -812,7 +810,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto* third_add_options = Object::create(global_object, nullptr);
// m. Let daysLater be ? CalendarDateAdd(calendar, relativeTo, daysDuration, thirdAddOptions, dateAdd).
- auto* days_later = TRY(calendar_date_add(global_object, *calendar, relative_to_date, *days_duration, third_add_options, date_add));
+ auto* days_later = TRY(calendar_date_add(global_object, *calendar, relative_to, *days_duration, third_add_options, date_add));
// n. Let untilOptions be ! OrdinaryObjectCreate(null).
auto* until_options = Object::create(global_object, nullptr);
@@ -821,7 +819,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "year"sv)));
// p. Let timePassed be ? CalendarDateUntil(calendar, relativeTo, daysLater, untilOptions).
- auto* time_passed = TRY(calendar_date_until(global_object, *calendar, relative_to_date, days_later, *until_options));
+ auto* time_passed = TRY(calendar_date_until(global_object, *calendar, relative_to, days_later, *until_options));
// q. Let yearsPassed be timePassed.[[Years]].
auto years_passed = time_passed->years();
@@ -830,7 +828,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
years += years_passed;
// s. Let oldRelativeTo be relativeTo.
- auto* old_relative_to_date = relative_to_date;
+ auto* old_relative_to = relative_to;
// t. Let yearsDuration be ? CreateTemporalDuration(yearsPassed, 0, 0, 0, 0, 0, 0, 0, 0, 0).
years_duration = TRY(create_temporal_duration(global_object, years_passed, 0, 0, 0, 0, 0, 0, 0, 0, 0));
@@ -839,10 +837,10 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto* fourth_add_options = Object::create(global_object, nullptr);
// v. Set relativeTo to ? CalendarDateAdd(calendar, relativeTo, yearsDuration, fourthAddOptions, dateAdd).
- relative_to_date = TRY(calendar_date_add(global_object, *calendar, relative_to_date, *years_duration, fourth_add_options, date_add));
+ relative_to = TRY(calendar_date_add(global_object, *calendar, relative_to, *years_duration, fourth_add_options, date_add));
// w. Let daysPassed be ? DaysUntil(oldRelativeTo, relativeTo).
- auto days_passed = days_until(global_object, *old_relative_to_date, *relative_to_date);
+ auto days_passed = days_until(global_object, *old_relative_to, *relative_to);
// x. Set days to days - daysPassed.
days -= days_passed;
@@ -857,25 +855,22 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
// aa. Let oneYear be ? CreateTemporalDuration(sign, 0, 0, 0, 0, 0, 0, 0, 0, 0).
auto* one_year = TRY(create_temporal_duration(global_object, sign, 0, 0, 0, 0, 0, 0, 0, 0, 0));
- // ab. Set relativeTo to ! CreateTemporalDateTime(relativeTo.[[ISOYear]], relativeTo.[[ISOMonth]], relativeTo.[[ISODay]], 0, 0, 0, 0, 0, 0, relativeTo.[[Calendar]]).
- relative_to = MUST(create_temporal_date_time(global_object, relative_to_date->iso_year(), relative_to_date->iso_month(), relative_to_date->iso_day(), 0, 0, 0, 0, 0, 0, relative_to->calendar()));
-
- // ac. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneYear).
+ // ab. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneYear).
auto move_result = TRY(move_relative_date(global_object, *calendar, *relative_to, *one_year));
- // ad. Let oneYearDays be moveResult.[[Days]].
+ // ac. Let oneYearDays be moveResult.[[Days]].
auto one_year_days = move_result.days;
- // ae. Let fractionalYears be years + days / abs(oneYearDays).
+ // ad. Let fractionalYears be years + days / abs(oneYearDays).
auto fractional_years = years + days / fabs(one_year_days);
- // af. Set years to ! RoundNumberToIncrement(fractionalYears, increment, roundingMode).
+ // ae. Set years to ! RoundNumberToIncrement(fractionalYears, increment, roundingMode).
years = (double)round_number_to_increment(fractional_years, increment, rounding_mode);
- // ag. Set remainder to fractionalYears - years.
+ // af. Set remainder to fractionalYears - years.
remainder = fractional_years - years;
- // ah. Set months, weeks, and days to 0.
+ // ag. Set months, weeks, and days to 0.
months = 0;
weeks = 0;
days = 0;
@@ -909,7 +904,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto weeks_in_days = days_until(global_object, *years_months_later, *years_months_weeks_later);
// i. Set relativeTo to yearsMonthsLater.
- auto* relative_to_date = years_months_later;
+ relative_to = years_months_later;
// j. Let days be days + weeksInDays.
days += weeks_in_days;
@@ -924,19 +919,16 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
// m. Let oneMonth be ? CreateTemporalDuration(0, sign, 0, 0, 0, 0, 0, 0, 0, 0).
auto* one_month = TRY(create_temporal_duration(global_object, 0, sign, 0, 0, 0, 0, 0, 0, 0, 0));
- // n. Set relativeTo to ! CreateTemporalDateTime(relativeTo.[[ISOYear]], relativeTo.[[ISOMonth]], relativeTo.[[ISODay]], 0, 0, 0, 0, 0, 0, relativeTo.[[Calendar]]).
- relative_to = MUST(create_temporal_date_time(global_object, relative_to_date->iso_year(), relative_to_date->iso_month(), relative_to_date->iso_day(), 0, 0, 0, 0, 0, 0, relative_to_date->calendar()));
-
- // o. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneMonth).
+ // n. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneMonth).
auto move_result = TRY(move_relative_date(global_object, *calendar, *relative_to, *one_month));
- // p. Set relativeTo to moveResult.[[RelativeTo]].
+ // o. Set relativeTo to moveResult.[[RelativeTo]].
relative_to = move_result.relative_to.cell();
- // q. Let oneMonthDays be moveResult.[[Days]].
+ // p. Let oneMonthDays be moveResult.[[Days]].
auto one_month_days = move_result.days;
- // r. Repeat, while abs(days) ≥ abs(oneMonthDays),
+ // q. Repeat, while abs(days) ≥ abs(oneMonthDays),
while (fabs(days) >= fabs(one_month_days)) {
// i. Set months to months + sign.
months += sign;
@@ -954,16 +946,16 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
one_month_days = move_result.days;
}
- // s. Let fractionalMonths be months + days / abs(oneMonthDays).
+ // r. Let fractionalMonths be months + days / abs(oneMonthDays).
auto fractional_months = months + days / fabs(one_month_days);
- // t. Set months to ! RoundNumberToIncrement(fractionalMonths, increment, roundingMode).
+ // s. Set months to ! RoundNumberToIncrement(fractionalMonths, increment, roundingMode).
months = (double)round_number_to_increment(fractional_months, increment, rounding_mode);
- // u. Set remainder to fractionalMonths - months.
+ // t. Set remainder to fractionalMonths - months.
remainder = fractional_months - months;
- // v. Set weeks and days to 0.
+ // u. Set weeks and days to 0.
weeks = 0;
days = 0;
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
index 7843d7f5c0..0527b2961c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
@@ -90,7 +90,7 @@ struct BalancedDuration {
// Used by MoveRelativeDate to temporarily hold values
struct MoveRelativeDateResult {
- Handle<PlainDateTime> relative_to;
+ Handle<PlainDate> relative_to;
double days;
};
@@ -153,7 +153,7 @@ ThrowCompletionOr<double> calculate_offset_shift(GlobalObject&, Value relative_t
BigInt* total_duration_nanoseconds(GlobalObject&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, BigInt const& nanoseconds, double offset_shift);
ThrowCompletionOr<BalancedDuration> balance_duration(GlobalObject&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, BigInt const& nanoseconds, String const& largest_unit, Object* relative_to = nullptr);
ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to);
-ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(GlobalObject&, Object& calendar, PlainDateTime& relative_to, Duration& duration);
+ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(GlobalObject&, Object& calendar, PlainDate& relative_to, Duration& duration);
ThrowCompletionOr<ZonedDateTime*> move_relative_zoned_date_time(GlobalObject&, ZonedDateTime&, double years, double months, double weeks, double days);
ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject&, 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<TemporalDuration> to_limited_temporal_duration(GlobalObject&, Value temporal_duration_like, Vector<StringView> const& disallowed_fields);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
index e144034fff..a00d9b58a7 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
@@ -488,12 +488,9 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::until)
// 14. If smallestUnit is not "day" or roundingIncrement ≠ 1, then
if (*smallest_unit != "day"sv || rounding_increment != 1) {
- // a. Let relativeTo be ! CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], 0, 0, 0, 0, 0, 0, temporalDate.[[Calendar]]).
- auto* relative_to = MUST(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), 0, 0, 0, 0, 0, 0, temporal_date->calendar()));
-
- // b. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, relativeTo).
+ // a. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, temporalDate).
// See NOTE above about why this is done.
- auto rounded_result = TRY(round_duration(global_object, years, months, weeks, days, 0, 0, 0, 0, 0, 0, rounding_increment, *smallest_unit, rounding_mode, relative_to));
+ auto rounded_result = TRY(round_duration(global_object, years, months, weeks, days, 0, 0, 0, 0, 0, 0, rounding_increment, *smallest_unit, rounding_mode, temporal_date));
years = rounded_result.years;
months = rounded_result.months;
weeks = rounded_result.weeks;
@@ -555,13 +552,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::since)
return TRY(create_temporal_duration(global_object, -result->years(), -result->months(), -result->weeks(), -result->days(), 0, 0, 0, 0, 0, 0));
}
- // 16. Let relativeTo be ! CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], 0, 0, 0, 0, 0, 0, temporalDate.[[Calendar]]).
- auto* relative_to = MUST(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), 0, 0, 0, 0, 0, 0, temporal_date->calendar()));
-
- // 17. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, relativeTo).
- auto round_result = TRY(round_duration(global_object, result->years(), result->months(), result->weeks(), result->days(), 0, 0, 0, 0, 0, 0, rounding_increment, *smallest_unit, rounding_mode, relative_to));
+ // 16. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, temporalDate).
+ auto round_result = TRY(round_duration(global_object, result->years(), result->months(), result->weeks(), result->days(), 0, 0, 0, 0, 0, 0, rounding_increment, *smallest_unit, rounding_mode, temporal_date));
- // 18. Return ? CreateTemporalDuration(−result.[[Years]], −result.[[Months]], −result.[[Weeks]], −result.[[Days]], 0, 0, 0, 0, 0, 0).
+ // 17. Return ? CreateTemporalDuration(−result.[[Years]], −result.[[Months]], −result.[[Weeks]], −result.[[Days]], 0, 0, 0, 0, 0, 0).
// NOTE: `result` here refers to `round_result`.
return TRY(create_temporal_duration(global_object, -round_result.years, -round_result.months, -round_result.weeks, -round_result.days, 0, 0, 0, 0, 0, 0));
}