UNPKG

@hebcal/hdate

Version:

converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold

36 lines (34 loc) 954 B
/*! @hebcal/hdate v0.14.4, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */ /** * Formats a number with leading zeros so the resulting string is 4 digits long. * Similar to `string.padStart(4, '0')` but will also format * negative numbers similar to how the JavaScript date formats * negative year numbers (e.g. `-37` is formatted as `-000037`). */ function pad4(num) { if (num < 0) { return '-00' + pad4(-num); } else if (num < 10) { return '000' + num; } else if (num < 100) { return '00' + num; } else if (num < 1000) { return '0' + num; } return String(num); } /** * Formats a number with leading zeros so the resulting string is 2 digits long. * Similar to `string.padStart(2, '0')`. */ function pad2(num) { if (num >= 0 && num < 10) { return '0' + num; } return String(num); } export { pad2, pad4 }; //# sourceMappingURL=pad.js.map