Skip to content

Commit 6e9e150

Browse files
MaleDongrubys
MaleDong
authored andcommitted
util: Fix number format for pad
`pad` is now using `toString(10)`, actually we don't need to do this. As for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString, `toString(N)` is a radix converter, which isn't proper here for time conversion. PR-URL: #21906 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Ruby <[email protected]>
1 parent 36696cf commit 6e9e150

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ function isPrimitive(arg) {
13491349
}
13501350

13511351
function pad(n) {
1352-
return n < 10 ? `0${n.toString(10)}` : n.toString(10);
1352+
return n.toString().padStart(2, '0');
13531353
}
13541354

13551355
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',

0 commit comments

Comments
 (0)