UNPKG

date-fns

Version:

Modern JavaScript date utility library

8 lines (7 loc) 244 B
"use strict"; exports.addLeadingZeros = addLeadingZeros; function addLeadingZeros(number, targetLength) { const sign = number < 0 ? "-" : ""; const output = Math.abs(number).toString().padStart(targetLength, "0"); return sign + output; }