aboutsummaryrefslogtreecommitdiffstats
path: root/library/moment/src/lib/utils/zero-fill.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/moment/src/lib/utils/zero-fill.js')
-rw-r--r--library/moment/src/lib/utils/zero-fill.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/moment/src/lib/utils/zero-fill.js b/library/moment/src/lib/utils/zero-fill.js
new file mode 100644
index 000000000..7009ec903
--- /dev/null
+++ b/library/moment/src/lib/utils/zero-fill.js
@@ -0,0 +1,7 @@
+export default function zeroFill(number, targetLength, forceSign) {
+ var absNumber = '' + Math.abs(number),
+ zerosToFill = targetLength - absNumber.length,
+ sign = number >= 0;
+ return (sign ? (forceSign ? '+' : '') : '-') +
+ Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
+}