mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibJS: Make ToDateDurationRecordWithoutTime infallible
This is an editorial change in the Temporal proposal. See: https://github.com/tc39/proposal-temporal/commit/05017b9
This commit is contained in:
@@ -110,7 +110,7 @@ InternalDuration to_internal_duration_record_with_24_hour_days(VM& vm, Duration
|
||||
}
|
||||
|
||||
// 7.5.7 ToDateDurationRecordWithoutTime ( duration ), https://tc39.es/proposal-temporal/#sec-temporal-todatedurationrecordwithouttime
|
||||
ThrowCompletionOr<DateDuration> to_date_duration_record_without_time(VM& vm, Duration const& duration)
|
||||
DateDuration to_date_duration_record_without_time(VM& vm, Duration const& duration)
|
||||
{
|
||||
// 1. Let internalDuration be ToInternalDurationRecordWith24HourDays(duration).
|
||||
auto internal_duration = to_internal_duration_record_with_24_hour_days(vm, duration);
|
||||
@@ -118,8 +118,8 @@ ThrowCompletionOr<DateDuration> to_date_duration_record_without_time(VM& vm, Dur
|
||||
// 2. Let days be truncate(internalDuration.[[Time]] / nsPerDay).
|
||||
auto days = internal_duration.time.divided_by(NANOSECONDS_PER_DAY).quotient;
|
||||
|
||||
// 3. Return ? CreateDateDurationRecord(internalDuration.[[Date]].[[Years]], internalDuration.[[Date]].[[Months]], internalDuration.[[Date]].[[Weeks]], days).
|
||||
return TRY(create_date_duration_record(vm, duration.years(), duration.months(), duration.weeks(), days.to_double()));
|
||||
// 3. Return ! CreateDateDurationRecord(internalDuration.[[Date]].[[Years]], internalDuration.[[Date]].[[Months]], internalDuration.[[Date]].[[Weeks]], days).
|
||||
return MUST(create_date_duration_record(vm, duration.years(), duration.months(), duration.weeks(), days.to_double()));
|
||||
}
|
||||
|
||||
// 7.5.8 TemporalDurationFromInternal ( internalDuration, largestUnit ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldurationfrominternal
|
||||
|
||||
Reference in New Issue
Block a user