summaryrefslogtreecommitdiff
path: root/node_modules/moment/src/lib/utils/zero-fill.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/moment/src/lib/utils/zero-fill.js')
-rw-r--r--node_modules/moment/src/lib/utils/zero-fill.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/node_modules/moment/src/lib/utils/zero-fill.js b/node_modules/moment/src/lib/utils/zero-fill.js
new file mode 100644
index 0000000..e2d2f6e
--- /dev/null
+++ b/node_modules/moment/src/lib/utils/zero-fill.js
@@ -0,0 +1,10 @@
+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
+ );
+}