aboutsummaryrefslogblamecommitdiffstats
path: root/library/moment/src/lib/utils/zero-fill.js
blob: 7009ec903d336d5ec9489d5dd81b8afae028a86b (plain) (tree)
1
2
3
4
5
6
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;
}