Class: Calendars

Calendars

new Calendars()

Create the calendars plugin.

Provides support for various world calendars in a consistent manner.

Use the global instance, $.calendars, to access the functionality.

Source:
Example
$.calendars.instance('julian').newDate(2014, 12, 25)

Members

(static) this.regionalOptions['']

Localised values.
Properties:
Name Type Attributes Default Description
invalidCalendar string <optional>
'Calendar {0} not found' Error message for an unknown calendar.
invalidDate string <optional>
'Invalid {0} date' Error message for an invalid date for this calendar.
invalidMonth string <optional>
'Invalid {0} month' Error message for an invalid month for this calendar.
invalidYear string <optional>
'Invalid {0} year' Error message for an invalid year for this calendar.
differentCalendars string <optional>
'Cannot mix {0} and {1} dates' Error message for mixing different calendars.
Source:

Methods

(static) instance(nameopt, languageopt) → {Calendar}

Obtain a calendar implementation and localisation.
Parameters:
Name Type Attributes Default Description
name string <optional>
'gregorian' The name of the calendar, e.g. 'gregorian', 'persian', 'islamic'.
language string <optional>
'' The language code to use for localisation (default is English).
Source:
Throws:
Error if calendar not found.
Returns:
The calendar and localisation.
Type
Calendar
Example
$.calendars.instance()
$.calendars.instance('persian')
$.calendars.instance('hebrew', 'he')

(static) newDate(yearopt, monthopt, dayopt, calendaropt, languageopt) → {CDate}

Create a new date - for today if no other parameters given.
Parameters:
Name Type Attributes Default Description
year CDate | number <optional>
The date to copy or the year for the date.
month number <optional>
The month for the date (if numeric year specified above).
day number <optional>
The day for the date (if numeric year specified above).
calendar BaseCalendar | string <optional>
'gregorian' The underlying calendar or the name of the calendar.
language string <optional>
'' The language to use for localisation (default English).
Source:
Throws:
Error if an invalid date.
Returns:
The new date.
Type
CDate
Example
$.calendars.newDate()
$.calendars.newDate(otherDate)
$.calendars.newDate(2001, 1, 1)
$.calendars.newDate(1379, 10, 12, 'persian')

(static) substituteChineseDigits(digits, powers) → {CalendarsDigits}

Digit substitution function for localising Chinese style numbers via the Calendar digits option.
Parameters:
Name Type Description
digits Array.<string> The substitute digits, for 0 through 9.
powers Array.<string> The characters denoting powers of 10, i.e. 1, 10, 100, 1000.
Source:
Returns:
The substitution function.
Type
CalendarsDigits
Example
digits: $.calendars.substituteChineseDigits(
  ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九'], ['', '十', '百', '千'])

(static) substituteDigits(digits) → {CalendarsDigits}

A simple digit substitution function for localising numbers via the Calendar digits option.
Parameters:
Name Type Description
digits Array.<string> The substitute digits, for 0 through 9.
Source:
Returns:
The substitution function.
Type
CalendarsDigits
Example
digits: $.calendars.substituteDigits(['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'])