CalendarSystem

Defines the standard interface for a calendar system. Each calendar system must implement this contract.

Props

The following table outlines the props for the CalendarSystem:

NameTypeDefaultDescription
name
string
-

The unique name of the calendar system (e.g., "gregorian").

Methods

The following table outlines the methods for the CalendarSystem:

NameParametersReturnsDescription
addDays
  • d

    : Date
  • n

    : number
  • Date

    Returns a new date that is n days after (or before if negative) the given date.


    Params:
  • d: The input date.
  • n: Number of days to add (negative to subtract).
  • addMonths
  • date

    : Date
  • months

    : number
  • Date

    Returns a new date that is the given number of months from the input date.


    Params:
  • date: The input date.
  • months: Number of months to add (negative to subtract).
  • addYears
  • date

    : Date
  • years

    : number
  • Date

    Returns a new date that is the given number of years from the input date.


    Params:
  • date: The input date.
  • years: Number of years to add (negative to subtract).
  • endOfMonth
  • d

    : Date
  • Date

    Returns a new date representing the end of the month for the given date.


    Params:
  • d: The input date.
  • endOfYear
  • d

    : Date
  • Date

    Returns a new date representing the end of the year for the given date.


    Params:
  • d: The input date.
  • getDay
  • date

    : Date
  • number

    Gets the day of the month component of the given date.


    Params:
  • date: The input date.
  • getDaysInMonth
  • year

    : number
  • month

    : number
  • number

    Returns the number of days in the given calendar-system month/year.


    Params:
  • year: Calendar-system year.
  • month: Zero-based calendar-system month (0-11).
  • getDecadeMatrix
  • baseDate

    : Date
  • options?

    : CalendarOptions
  • Builds a decade view matrix (typically 4x3) for the given base date.


    Params:
  • baseDate: The base date from which the view is generated.
  • options: Matrix generation options (rows, cols).
  • getMonth
  • date

    : Date
  • number

    Gets the zero-based calendar month component of the given date.


    Params:
  • date: The input date.
  • getMonthMatrix
  • baseDate

    : Date
  • options?

    : CalendarOptions
  • Builds a month view matrix (typically 6x7) for the given base date.


    Params:
  • baseDate: The base date from which the view is generated.
  • options: Matrix generation options (e.g., firstDayOfWeek, rows, cols).
  • getMonthName
    -
    string

    Returns the localized name for a specific month.

    getWeekDayNames
  • locale

    : string
  • firstDayOfWeek

    : number
  • weekDaysFormat

    : string
  • string[]

    Returns localized names for the days of the week in display order, starting from firstDayOfWeek.


    Params:
  • locale: A BCP 47 language tag (e.g., "en", "en-US").
  • firstDayOfWeek: The first day of the week (0 = Sunday, 1 = Monday, ...).
  • weekDaysFormat: The name format for week days. Expected values: "Short" | "Narrow" | "Abbreviated" | "Wide".
  • getWeekNumber
  • date

    : Date
  • number

    Calculates the week number for a given date based on the calendar's WeekRule and first day of week rules.


    Params:
  • date: The input date.
  • getYear
  • date

    : Date
  • number

    Gets the calendar year component of the given date.


    Params:
  • date: The input date.
  • getYearMatrix
  • baseDate

    : Date
  • options?

    : CalendarOptions
  • Builds a year view matrix (typically 4x3) for the given base date.


    Params:
  • baseDate: The base date from which the view is generated.
  • options: Matrix generation options (rows, cols).
  • isSameDate
  • date1

    : Date
  • date2

    : Date
  • boolean

    Determines whether two dates are same.


    Params:
  • date1: The first date.
  • date2: The second date.
  • isSameMonth
  • date1

    : Date
  • date2

    : Date
  • boolean

    Determines whether two dates are in the same calendar month and year.


    Params:
  • date1: The first date.
  • date2: The second date.
  • isSameYear
  • date1

    : Date
  • date2

    : Date
  • boolean

    Determines whether two Year are same.


    Params:
  • date1: The first date.
  • date2: The second date.
  • startOfDecade
  • d

    : Date
  • Date

    Returns a new date representing the start of the decade for the given date.


    Params:
  • d: The input date.
  • startOfMonth
  • d

    : Date
  • Date

    Returns a new date representing the start of the month for the given date.


    Params:
  • d: The input date.
  • startOfYear
  • d

    : Date
  • Date

    Returns a new date representing the start of the year for the given date.


    Params:
  • d: The input date.
  • toDate
  • year

    : number
  • month

    : number
  • day

    : number
  • hour?

    : number
  • minute?

    : number
  • second?

    : number
  • Date

    Creates a Date object from the given date and time components.


    Params:
  • year: The full year (e.g., 2026).
  • month: The month index (0-11, where 0 = January and 11 = December).
  • day: The day of the month (1-31).
  • hour: The hour of the day (0-23). Optional.
  • minute: The minute of the hour (0-59). Optional.
  • second: The second of the minute (0-59). Optional.