Function padTo2Digits

  • 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

    padTo2Digits(7)
    // => { ok: true, value: '07' }

    Example

    Handle invalid input:

    padTo2Digits("hello")
    // => { ok: false, error: Error('[dates.padTo2Digits] Expected number value as input') }

    Parameters

    • num: number

      The number to pad.

    Returns Result<string, Error>

    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.

Generated using TypeDoc v0.24.7