Skip to content

Commit

Permalink
util: Fix number format for pad
Browse files Browse the repository at this point in the history
`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]>
  • Loading branch information
MaleDong authored and targos committed Sep 3, 2018
1 parent e8e014a commit f86ca89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ function isPrimitive(arg) {
}

function pad(n) {
return n < 10 ? `0${n.toString(10)}` : n.toString(10);
return n.toString().padStart(2, '0');
}

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

0 comments on commit f86ca89

Please sign in to comment.