convnum
    Preparing search index...

    Function formatMonthString

    • Formats a month number (months since 1970-01) according to the specified format string. This function only works with year-month formats (no day component).

      Parameters

      • months: number

        Number of months since 1970-01 (1970-01 = 0, 1970-02 = 1, etc.)

      • format: string

        Format string for year-month only (e.g., "Y-M1", "Y.M2", "Mf Y")

      Returns string

      Formatted date string containing only year and month

      Error if the format string contains day components or is invalid

      formatMonthString(0, 'Y-M1') // '1970-1'
      formatMonthString(1, 'Y-M2') // '1970-02'
      formatMonthString(12, 'Y-M1') // '1971-1'
      formatMonthString(0, 'Mf Y') // 'January 1970'
      formatMonthString(11, 'Ms Y') // 'Dec 1970'