Function buildYearList

  • Builds a list of years for selection dropdowns, combining Gregorian and Persian years.

    Creates an array of year objects with both Gregorian and Persian year representations. The list starts from the current year and goes back by the specified number of years.

    Parameters

    • base: number = 50

      Number of years to go back from the current year. Defaults to 50.

    Returns { id: number; title: string }[]

    Array of year objects with title (formatted string) and id (Persian year number).

    const years = buildYearsList(10);
    console.log(years[0]); // { title: "2025 - 1404", id: 1404 }
    const years = buildYearsList(5);
    console.log(years.length); // 6 (current year + 5 previous years)