timepiece/node_modules/date-fns/_lib/addLeadingZeros.mjs

6 lines
194 B
JavaScript
Raw Normal View History

2024-05-14 14:54:12 +00:00
export function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? "-" : "";
const output = Math.abs(number).toString().padStart(targetLength, "0");
return sign + output;
}