From 4edc8f8c334519907b04371e8bfe9e83e6294778 Mon Sep 17 00:00:00 2001 From: MaleDong Date: Fri, 20 Jul 2018 15:55:27 +0800 Subject: [PATCH] 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. --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 3d3bbdb6120fa2..453f9ece98e5db 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1326,7 +1326,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',