@@ -323,14 +323,14 @@ export class Duration {
323323 nanoseconds
324324 ) ;
325325 options = ES . GetOptionsObject ( options ) ;
326- let smallestUnit = ES . ToSmallestTemporalDurationUnit ( options , undefined ) ;
326+ let smallestUnit = ES . ToSmallestTemporalUnit ( options , undefined ) ;
327327 let smallestUnitPresent = true ;
328328 if ( ! smallestUnit ) {
329329 smallestUnitPresent = false ;
330- smallestUnit = 'nanoseconds ' ;
330+ smallestUnit = 'nanosecond ' ;
331331 }
332- defaultLargestUnit = ES . LargerOfTwoTemporalDurationUnits ( defaultLargestUnit , smallestUnit ) ;
333- let largestUnit = ES . ToLargestTemporalDurationUnit ( options ) ;
332+ defaultLargestUnit = ES . LargerOfTwoTemporalUnits ( defaultLargestUnit , smallestUnit ) ;
333+ let largestUnit = ES . ToLargestTemporalUnit ( options , undefined ) ;
334334 let largestUnitPresent = true ;
335335 if ( ! largestUnit ) {
336336 largestUnitPresent = false ;
@@ -342,19 +342,7 @@ export class Duration {
342342 }
343343 ES . ValidateTemporalUnitRange ( largestUnit , smallestUnit ) ;
344344 const roundingMode = ES . ToTemporalRoundingMode ( options , 'halfExpand' ) ;
345- const maximumIncrements = {
346- years : undefined ,
347- months : undefined ,
348- weeks : undefined ,
349- days : undefined ,
350- hours : 24 ,
351- minutes : 60 ,
352- seconds : 60 ,
353- milliseconds : 1000 ,
354- microseconds : 1000 ,
355- nanoseconds : 1000
356- } ;
357- const roundingIncrement = ES . ToTemporalRoundingIncrement ( options , maximumIncrements [ smallestUnit ] , false ) ;
345+ const roundingIncrement = ES . ToTemporalDateTimeRoundingIncrement ( options , smallestUnit ) ;
358346 let relativeTo = ES . ToRelativeTemporalObject ( options ) ;
359347
360348 ( { years, months, weeks, days } = ES . UnbalanceDurationRelative (
@@ -495,7 +483,8 @@ export class Duration {
495483 toString ( options = undefined ) {
496484 if ( ! ES . IsTemporalDuration ( this ) ) throw new TypeError ( 'invalid receiver' ) ;
497485 options = ES . GetOptionsObject ( options ) ;
498- const { precision, unit, increment } = ES . ToDurationSecondsStringPrecision ( options ) ;
486+ const { precision, unit, increment } = ES . ToSecondsStringPrecision ( options ) ;
487+ if ( precision === 'minute' ) throw new RangeError ( 'smallestUnit must not be "minute"' ) ;
499488 const roundingMode = ES . ToTemporalRoundingMode ( options , 'trunc' ) ;
500489 return ES . TemporalDurationToString ( this , precision , { unit, increment, roundingMode } ) ;
501490 }
@@ -559,8 +548,8 @@ export class Duration {
559548 const shift1 = ES . CalculateOffsetShift ( relativeTo , y1 , mon1 , w1 , d1 , h1 , min1 , s1 , ms1 , µs1 , ns1 ) ;
560549 const shift2 = ES . CalculateOffsetShift ( relativeTo , y2 , mon2 , w2 , d2 , h2 , min2 , s2 , ms2 , µs2 , ns2 ) ;
561550 if ( y1 !== 0 || y2 !== 0 || mon1 !== 0 || mon2 !== 0 || w1 !== 0 || w2 !== 0 ) {
562- ( { days : d1 } = ES . UnbalanceDurationRelative ( y1 , mon1 , w1 , d1 , 'days ' , relativeTo ) ) ;
563- ( { days : d2 } = ES . UnbalanceDurationRelative ( y2 , mon2 , w2 , d2 , 'days ' , relativeTo ) ) ;
551+ ( { days : d1 } = ES . UnbalanceDurationRelative ( y1 , mon1 , w1 , d1 , 'day ' , relativeTo ) ) ;
552+ ( { days : d2 } = ES . UnbalanceDurationRelative ( y2 , mon2 , w2 , d2 , 'day ' , relativeTo ) ) ;
564553 }
565554 ns1 = ES . TotalDurationNanoseconds ( d1 , h1 , min1 , s1 , ms1 , µs1 , ns1 , shift1 ) ;
566555 ns2 = ES . TotalDurationNanoseconds ( d2 , h2 , min2 , s2 , ms2 , µs2 , ns2 , shift2 ) ;
0 commit comments