Options
All
  • Public
  • Public/Protected
  • All
Menu

A base class for all calendars.

Hierarchy

Index

Constructors

  • new Calendar(id: string, type: string): Calendar

Properties

#id: string
#type: string

Accessors

  • get id(): string
  • get type(): string
  • Calendar's type (Gregorian, Chiness, Persian, Islamic, ...). It is possible that you have multiple calendars with the same type and different ID's (multiple implementations for a specific calendar).

    Returns string

Methods

  • add(ts: number, units: Partial<DateTimeUnits>): number
  • Adds a period of time to a timestamp and returns the resulting timestamp.

    Parameters

    • ts: number
    • units: Partial<DateTimeUnits>

    Returns number

  • addMonths(ts: number, months: number): number
  • Adds the specified number of months to the given timestamp and returns the resulting timestamp.

    Parameters

    • ts: number

      timestamp

    • months: number

    Returns number

  • addYears(ts: number, years: number): number
  • Adds the specified number of years to the given timestamp and returns the resulting timestamp.

    Parameters

    • ts: number

      timestamp

    • years: number

    Returns number

  • dayOfYear(ts: number): number
  • daysInMonth(year: number, month: number): number
  • Returns the number of days in the given year and month. The month count starts with 1, up to 12.

    Parameters

    • year: number
    • month: number

    Returns number

  • daysInYear(year: number): number
  • getTimestamp(units: DateTimeUnits): number
  • Returns a timestamp equivalent to the given DateTimeUnits

    Parameters

    • units: DateTimeUnits

      DateTimeUnits

    Returns number

  • getUnits(ts: number): DateTimeUnits
  • Returns a DateTimeUnits(year, month, ...) equivalent to the given timestamp

    Parameters

    • ts: number

      timestamp

    Returns DateTimeUnits

  • isLeapYear(year: number): boolean
  • Returns true if this DateTime is in a leap year, false otherwise.

    Parameters

    • year: number

      year

    Returns boolean

  • isValid(year: number, month: number, day: number): boolean
  • Returns true if the given date is valid, otherwise returns false.

    Parameters

    • year: number
    • month: number
    • day: number

    Returns boolean

  • subtract(ts: number, units: Partial<DateTimeUnits>): number
  • Subtracts a period of time from a timestamp and returns the resulting timestamp.

    Parameters

    • ts: number
    • units: Partial<DateTimeUnits>

    Returns number

  • weekDay(time: number): number
  • weekNumber(ts: number, firstDayOfWeek: number, offset?: number): number
  • Gets the week number of the week year (1 to 52).

    Parameters

    • ts: number

      timestamp

    • firstDayOfWeek: number
    • offset: number = 1

    Returns number

Generated using TypeDoc