@@ -2370,11 +2370,6 @@ interface ToStringOptions {
2370
2370
roundingMode : ReturnType < typeof GetRoundingModeOption > ;
2371
2371
}
2372
2372
2373
- function formatAsDecimalNumber ( num : number | JSBI ) : string {
2374
- if ( typeof num === 'number' && num <= Number . MAX_SAFE_INTEGER ) return num . toString ( 10 ) ;
2375
- return JSBI . BigInt ( num ) . toString ( ) ;
2376
- }
2377
-
2378
2373
export function TemporalDurationToString (
2379
2374
duration : Temporal . Duration ,
2380
2375
precision : Exclude < SecondsStringPrecisionRecord [ 'precision' ] , 'minute' >
@@ -2388,14 +2383,14 @@ export function TemporalDurationToString(
2388
2383
const sign = DurationSign ( duration ) ;
2389
2384
2390
2385
let datePart = '' ;
2391
- if ( years !== 0 ) datePart += `${ formatAsDecimalNumber ( Math . abs ( years ) ) } Y` ;
2392
- if ( months !== 0 ) datePart += `${ formatAsDecimalNumber ( Math . abs ( months ) ) } M` ;
2393
- if ( weeks !== 0 ) datePart += `${ formatAsDecimalNumber ( Math . abs ( weeks ) ) } W` ;
2394
- if ( days !== 0 ) datePart += `${ formatAsDecimalNumber ( Math . abs ( days ) ) } D` ;
2386
+ if ( years !== 0 ) datePart += `${ Math . abs ( years ) } Y` ;
2387
+ if ( months !== 0 ) datePart += `${ Math . abs ( months ) } M` ;
2388
+ if ( weeks !== 0 ) datePart += `${ Math . abs ( weeks ) } W` ;
2389
+ if ( days !== 0 ) datePart += `${ Math . abs ( days ) } D` ;
2395
2390
2396
2391
let timePart = '' ;
2397
- if ( hours !== 0 ) timePart += `${ formatAsDecimalNumber ( Math . abs ( hours ) ) } H` ;
2398
- if ( minutes !== 0 ) timePart += `${ formatAsDecimalNumber ( Math . abs ( minutes ) ) } M` ;
2392
+ if ( hours !== 0 ) timePart += `${ Math . abs ( hours ) } H` ;
2393
+ if ( minutes !== 0 ) timePart += `${ Math . abs ( minutes ) } M` ;
2399
2394
2400
2395
// Keeping sub-second units separate avoids losing precision after resolving
2401
2396
// any overflows from rounding
@@ -2412,7 +2407,7 @@ export function TemporalDurationToString(
2412
2407
[ 'second' , 'millisecond' , 'microsecond' , 'nanosecond' ] . includes ( DefaultTemporalLargestUnit ( duration ) ) ||
2413
2408
precision !== 'auto'
2414
2409
) {
2415
- const secondsPart = formatAsDecimalNumber ( Math . abs ( secondsDuration . sec ) ) ;
2410
+ const secondsPart = Math . abs ( secondsDuration . sec ) ;
2416
2411
const subSecondsPart = FormatFractionalSeconds ( Math . abs ( secondsDuration . subsec ) , precision ) ;
2417
2412
timePart += `${ secondsPart } ${ subSecondsPart } S` ;
2418
2413
}
0 commit comments