@@ -3224,6 +3224,7 @@ function NudgeToCalendarUnit(
32243224 // Create a duration with smallestUnit trunc'd towards zero
32253225 // Create a separate duration that incorporates roundingIncrement
32263226 let r1 , r2 , startDuration , endDuration ;
3227+ var didExpandCalendarUnit = false ;
32273228 const compare = ( d1 , d2 ) => CompareDurations ( d1 , d2 , undefined , ToTemporalDate ( isoDateTime . isoDate ) , unit , unit ) ;
32283229 switch ( unit ) {
32293230 case 'year' : {
@@ -3235,6 +3236,7 @@ function NudgeToCalendarUnit(
32353236 var cmpResult = compare ( CombineDateAndTimeDuration ( endDuration , TimeDuration . ZERO ) ,
32363237 duration ) ;
32373238 if ( ( sign > 0 && cmpResult != 1 ) || ( sign < 0 && cmpResult != - 1 ) ) {
3239+ didExpandCalendarUnit = true ;
32383240 r1 = r2 ;
32393241 r2 = years + ( increment * 2 ) * sign ;
32403242 endDuration = { ...endDuration , years : r2 } ;
@@ -3254,6 +3256,7 @@ function NudgeToCalendarUnit(
32543256 var cmpResult = compare ( CombineDateAndTimeDuration ( endDuration , TimeDuration . ZERO ) ,
32553257 duration ) ;
32563258 if ( ( sign > 0 && cmpResult != 1 ) || ( sign < 0 && cmpResult != - 1 ) ) {
3259+ didExpandCalendarUnit = true ;
32573260 r1 = r2 ;
32583261 r2 = months + ( increment * 2 ) * sign ;
32593262 endDuration = AdjustDateDurationRecord ( duration . date , 0 , 0 , r2 ) ;
@@ -3297,7 +3300,7 @@ function NudgeToCalendarUnit(
32973300 // If the start of the bound is the same as the "origin" (aka relativeTo),
32983301 // use the origin's epoch-nanoseconds as-is instead of relying on isoDateTime,
32993302 // which then gets zoned and converted back to epoch-nanoseconds,
3300- // which looses precision and creates a distorted bounding window.
3303+ // which loses precision and creates a distorted bounding window.
33013304 startEpochNs = originEpochNs ;
33023305 } else {
33033306 const start = CalendarDateAdd ( calendar , isoDateTime . isoDate , startDuration , 'constrain' ) ;
@@ -3335,7 +3338,7 @@ function NudgeToCalendarUnit(
33353338 assert ( MathAbs ( r1 ) <= MathAbs ( total ) && MathAbs ( total ) <= MathAbs ( r2 ) , 'r1 ≤ total ≤ r2' ) ;
33363339
33373340 // Determine whether expanded or contracted
3338- const didExpandCalendarUnit = roundedUnit === MathAbs ( r2 ) ;
3341+ didExpandCalendarUnit | = roundedUnit === MathAbs ( r2 ) ;
33393342 duration = { date : didExpandCalendarUnit ? endDuration : startDuration , time : TimeDuration . ZERO } ;
33403343
33413344 const nudgeResult = {
0 commit comments