@@ -45,7 +45,7 @@ impl<C: CalendarProtocol> Date<C> {
45
45
duration : & Duration ,
46
46
context : & mut C :: Context ,
47
47
) -> TemporalResult < ( Self , f64 ) > {
48
- let new_date = self . add_date ( duration, ArithmeticOverflow :: Constrain , context) ?;
48
+ let new_date = self . add_date ( duration, None , context) ?;
49
49
let days = f64:: from ( self . days_until ( & new_date) ) ;
50
50
Ok ( ( new_date, days) )
51
51
}
@@ -56,10 +56,11 @@ impl<C: CalendarProtocol> Date<C> {
56
56
pub ( crate ) fn add_date (
57
57
& self ,
58
58
duration : & Duration ,
59
- overflow : ArithmeticOverflow ,
59
+ overflow : Option < ArithmeticOverflow > ,
60
60
context : & mut C :: Context ,
61
61
) -> TemporalResult < Self > {
62
62
// 2. If options is not present, set options to undefined.
63
+ let overflow = overflow. unwrap_or ( ArithmeticOverflow :: Constrain ) ;
63
64
// 3. If duration.[[Years]] ≠ 0, or duration.[[Months]] ≠ 0, or duration.[[Weeks]] ≠ 0, then
64
65
if duration. date ( ) . years != 0.0
65
66
|| duration. date ( ) . months != 0.0
@@ -81,7 +82,7 @@ impl<C: CalendarProtocol> Date<C> {
81
82
// 7. Let result be ? AddISODate(plainDate.[[ISOYear]], plainDate.[[ISOMonth]], plainDate.[[ISODay]], 0, 0, 0, days, overflow).
82
83
let result = self
83
84
. iso
84
- . add_iso_date ( & DateDuration :: new ( 0f64 , 0f64 , 0f64 , days) ?, overflow) ?;
85
+ . add_date_duration ( & DateDuration :: new ( 0f64 , 0f64 , 0f64 , days) ?, overflow) ?;
85
86
86
87
Ok ( Self :: new_unchecked ( result, self . calendar ( ) . clone ( ) ) )
87
88
}
@@ -301,11 +302,7 @@ impl<C: CalendarProtocol> Date<C> {
301
302
overflow : Option < ArithmeticOverflow > ,
302
303
context : & mut C :: Context ,
303
304
) -> TemporalResult < Self > {
304
- self . add_date (
305
- duration,
306
- overflow. unwrap_or ( ArithmeticOverflow :: Constrain ) ,
307
- context,
308
- )
305
+ self . add_date ( duration, overflow, context)
309
306
}
310
307
311
308
pub fn contextual_subtract (
@@ -314,11 +311,7 @@ impl<C: CalendarProtocol> Date<C> {
314
311
overflow : Option < ArithmeticOverflow > ,
315
312
context : & mut C :: Context ,
316
313
) -> TemporalResult < Self > {
317
- self . add_date (
318
- & duration. negated ( ) ,
319
- overflow. unwrap_or ( ArithmeticOverflow :: Constrain ) ,
320
- context,
321
- )
314
+ self . add_date ( & duration. negated ( ) , overflow, context)
322
315
}
323
316
324
317
pub fn contextual_until (
0 commit comments