PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/moment/src/lib/utils/zero-fill.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 7 lines | 7 code | 0 blank | 0 comment | 0 complexity | 71ddff4ec0ba668921e523b2c92e20fe MD5 | raw file
1export default function zeroFill(number, targetLength, forceSign) {
2    var absNumber = '' + Math.abs(number),
3        zerosToFill = targetLength - absNumber.length,
4        sign = number >= 0;
5    return (sign ? (forceSign ? '+' : '') : '-') +
6        Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
7}