Pads a number to exactly 2 digits with leading zeros. Used if the month and day values only contain a single digit (are less than 10).
padTo2Digits(7)// => { ok: true, value: '07' } Copy
padTo2Digits(7)// => { ok: true, value: '07' }
Handle invalid input:
padTo2Digits("hello")// => { ok: false, error: Error('[dates.padTo2Digits] Expected number value as input') } Copy
padTo2Digits("hello")// => { ok: false, error: Error('[dates.padTo2Digits] Expected number value as input') }
The number to pad.
A Result object with either the padded number as a string on success, or an Error object if the provided input is not a number.
Result
Error
Generated using TypeDoc v0.24.7
Pads a number to exactly 2 digits with leading zeros. Used if the month and day values only contain a single digit (are less than 10).
Example
Example
Handle invalid input: