Skip to content

Commit 29ea965

Browse files
committed
Remove formatAsDecimalNumber dead code
All call sites of this function provide safe integers and convert the result to a string, so it's a no-op.
1 parent 2ecc4e9 commit 29ea965

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lib/ecmascript.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,11 +2370,6 @@ interface ToStringOptions {
23702370
roundingMode: ReturnType<typeof GetRoundingModeOption>;
23712371
}
23722372

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-
23782373
export function TemporalDurationToString(
23792374
duration: Temporal.Duration,
23802375
precision: Exclude<SecondsStringPrecisionRecord['precision'], 'minute'>
@@ -2388,14 +2383,14 @@ export function TemporalDurationToString(
23882383
const sign = DurationSign(duration);
23892384

23902385
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`;
23952390

23962391
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`;
23992394

24002395
// Keeping sub-second units separate avoids losing precision after resolving
24012396
// any overflows from rounding
@@ -2412,7 +2407,7 @@ export function TemporalDurationToString(
24122407
['second', 'millisecond', 'microsecond', 'nanosecond'].includes(DefaultTemporalLargestUnit(duration)) ||
24132408
precision !== 'auto'
24142409
) {
2415-
const secondsPart = formatAsDecimalNumber(Math.abs(secondsDuration.sec));
2410+
const secondsPart = Math.abs(secondsDuration.sec);
24162411
const subSecondsPart = FormatFractionalSeconds(Math.abs(secondsDuration.subsec), precision);
24172412
timePart += `${secondsPart}${subSecondsPart}S`;
24182413
}

0 commit comments

Comments
 (0)