Skip to content

Commit 4160465

Browse files
committed
Make bubble_relative_duration parameters align with the spec
1 parent 478c5f8 commit 4160465

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/builtins/core/duration/normalized.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
primitive::FiniteF64,
1515
provider::TimeZoneProvider,
1616
rounding::{IncrementRounder, Round},
17-
TemporalError, TemporalResult, TemporalUnwrap, NS_PER_DAY,
17+
Calendar, TemporalError, TemporalResult, TemporalUnwrap, NS_PER_DAY,
1818
};
1919

2020
use super::{DateDuration, Duration, Sign, TimeDuration};
@@ -782,12 +782,14 @@ impl NormalizedDurationRecord {
782782
//
783783
// spec(2025-05-28): https://github.com/tc39/proposal-temporal/tree/69001e954c70e29ba3d2e6433bc7ece2a037377a
784784
#[inline]
785+
#[allow(clippy::too_many_arguments)]
785786
fn bubble_relative_duration(
786787
&self,
787788
sign: Sign,
788789
nudged_epoch_ns: i128,
789-
date_time: &PlainDateTime,
790+
iso_date_time: &IsoDateTime,
790791
time_zone: Option<(&TimeZone, &impl TimeZoneProvider)>,
792+
calendar: &Calendar,
791793
largest_unit: Unit,
792794
smallest_unit: Unit,
793795
) -> TemporalResult<NormalizedDurationRecord> {
@@ -858,14 +860,14 @@ impl NormalizedDurationRecord {
858860
};
859861

860862
// iv. Let end be ? CalendarDateAdd(calendar, isoDateTime.[[ISODate]], endDuration, constrain).
861-
let end = date_time.calendar().date_add(
862-
&date_time.iso.date,
863+
let end = calendar.date_add(
864+
&iso_date_time.date,
863865
&Duration::from(end_duration),
864866
ArithmeticOverflow::Constrain,
865867
)?;
866868

867869
// v. Let endDateTime be CombineISODateAndTimeRecord(end, isoDateTime.[[Time]]).
868-
let end_date_time = IsoDateTime::new_unchecked(end.iso, date_time.iso.time);
870+
let end_date_time = IsoDateTime::new_unchecked(end.iso, iso_date_time.time);
869871

870872
let end_epoch_ns = match time_zone {
871873
// vi. If timeZone is unset, then
@@ -951,8 +953,9 @@ impl NormalizedDurationRecord {
951953
duration = duration.bubble_relative_duration(
952954
sign,
953955
nudge_result.nudge_epoch_ns,
954-
dt,
956+
&dt.iso,
955957
timezone_record,
958+
dt.calendar(),
956959
options.largest_unit,
957960
start_unit,
958961
)?

0 commit comments

Comments
 (0)