Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract class representing any calendar that can be converted from and to a Julian Day.

Hierarchy

Index

Constructors

constructor

  • This constructor is inherited by all subclasses (no implementation in subclass required).

    The constructor supports two signatures:

    • period: JDNPeriod creates a date from the given JDNPeriod (two JDNs)
    • period: CalendarPeriod creates a date from the given CalendarPeriod (two calendar dates)

    Parameters

    Returns JDNConvertibleCalendar

  • This constructor is inherited by all subclasses (no implementation in subclass required).

    The constructor supports two signatures:

    • period: JDNPeriod creates a date from the given JDNPeriod (two JDNs)
    • period: CalendarPeriod creates a date from the given CalendarPeriod (two calendar dates)

    Parameters

    Returns JDNConvertibleCalendar

Properties

Protected calendarEnd

calendarEnd: CalendarDate

End of a given date in a specific calendar.

Abstract calendarName

calendarName: string

Calendar name of a subclass of JDNConvertibleCalendar.

Protected calendarStart

calendarStart: CalendarDate

Start of a given date in a specific calendar.

Protected exactDate

exactDate: Boolean

Indicates if the date is exact (start and end of the given period are equal).

Protected jdnEnd

jdnEnd: JDN

End of given date as JDN.

Protected jdnStart

jdnStart: JDN

Start of given date as JDN.

Abstract monthsInYear

monthsInYear: number

Indicates how many months a year has in a specific calendar.

Abstract yearZeroExists

yearZeroExists: Boolean

Indicates if the year 0 exists in a specific calendar.

Static Protected gregorian

gregorian: "Gregorian" = "Gregorian"

Constant for the Gregorian calendar.

Static Protected islamic

islamic: "Islamic" = "Islamic"

Constant for the Islamic calendar.

Static Protected julian

julian: "Julian" = "Julian"

Constant for the Julian calendar.

Static supportedCalendars

supportedCalendars: string[] = [JDNConvertibleCalendar.gregorian, JDNConvertibleCalendar.julian, JDNConvertibleCalendar.islamic]

Supported calendars (to be extended when new subclasses are implemented).

Methods

Protected Abstract JDNToCalendar

  • Converts a given JDN to a calendar date. This method has to be implemented for each subclass (specific calendar).

    Attention: depending on the conventions used, there may be a year 0 or not. This depends on the implementation of this conversion function.

    Parameters

    • jdn: JDN

      JDN to be converted to a calendar date.

    Returns CalendarDate

    calendar date created from given JDN.

Protected Abstract calendarToJDN

  • Converts a given calendar date to JDN. This method has to be implemented for each subclass (specific calendar).

    Attention: depending on the conventions used, there may be a year 0 or not. This depends on the implementation of this conversion function.

    Parameters

    • date: CalendarDate

      calendar date to be converted to a JDN.

    Returns JDN

    JDN created from given calendar date.

convertCalendar

  • Converts from one calendar into another.

    To be extended when new subclasses are added.

    Parameters

    • toCalendarType: "Gregorian" | "Julian" | "Islamic"

      calendar to convert to.

    Returns JDNConvertibleCalendar

    instance of target calendar (subclass of JDNConvertibleCalendar).

Protected convertJDNPeriodToCalendarPeriod

  • convertJDNPeriodToCalendarPeriod(jdnPeriod: JDNPeriod): void
  • Converts the given JDN period to a calendar period and stores it.

    This method makes sure that JDNs and calendar dates are in sync. This method has no return value, it manipulates this.calendarStart, and this.calendarEnd instead.

    Do not manipulate members this.exactDate, this.jdnStart, this.jdnEnd, this.calendarStart, and this.calendarEnd directly, use this method instead.

    Parameters

    • jdnPeriod: JDNPeriod

      the period defined by JDNs to be converted to a calendar period.

    Returns void

Protected Abstract dayOfWeekFromJDN

  • dayOfWeekFromJDN(jdn: JDN): number
  • Calculates the day of week of a given JDN.

    Parameters

    • jdn: JDN

      JDN for which the day of the week is to be calculated.

    Returns number

    day of week of the given JDN (as a 0-based index).

daysInMonth

  • Calculates number of days for the month of the given date.

    The given date is expected to be of the same calendar as the instance the method is called on.

    Parameters

    Returns number

    number of days in month of given date.

Protected handleMonthTransposition

  • Converts the given calendar date to a new one, shifting the months by the given number.

    Parameters

    • calendarDate: CalendarDate

      the given calendar date.

    • months: number

      the number of months to shift.

    Returns CalendarDate

    calendar transposed by the given number of months.

toCalendarPeriod

toJDNPeriod

transposePeriodByDay

  • transposePeriodByDay(days: number): void
  • Transposes the current period by the given number of days.

    Parameters

    • days: number

      the number of days that the current period will be shifted.

    Returns void

transposePeriodByMonth

  • transposePeriodByMonth(months: number): void
  • Transposes the current period by the given number of months.

    This method is not accurate in the arithmetical sense: it tries to fit the given day in the new month. If this is not possible, it takes the last day of the new month (e.g., January 31 will become the last possible day of February).

    Parameters

    • months: number

      the number of months that the current period will be shifted.

    Returns void

transposePeriodByYear

  • transposePeriodByYear(years: number): void
  • Transposes the current period by the given number of years.

    This method is not accurate in the arithmetical sense: it tries to fit the given day in the month of the new year. If this is not possible, it takes the last day of the new month (e.g., February 29 will become the last possible day of February).

    Parameters

    • years: number

      the number of years that the current period will be shifted.

    Returns void

Generated using TypeDoc