Class: CDate

CDate

new CDate(calendar, year, month, day) → {CDate}

Generic date, based on a particular calendar.
Parameters:
Name Type Description
calendar BaseCalendar The underlying calendar implementation.
year number The year for this date.
month number The month for this date.
day number The day for this date.
Source:
Throws:
Error if an invalid date.
Returns:
The date object.
Type
CDate

Methods

(static) add(offset, period) → {CDate}

Add period(s) to a date.
Parameters:
Name Type Description
offset number The number of periods to adjust by.
period string One of 'y' for years, 'm' for months, 'w' for weeks, 'd' for days.
Source:
Returns:
The updated date.
Type
CDate
Example
date.add(10, 'd')

(static) calendar() → {BaseCalendar}

Retrieve the calendar backing this date.
Source:
Returns:
The calendar implementation.
Type
BaseCalendar
Example
var cal = date.calendar()

(static) compareTo(date) → {number}

Compare this date to another date.
Parameters:
Name Type Description
date CDate The other date.
Source:
Returns:
-1 if this date is before the other date, 0 if they are equal, or +1 if this date is after the other date.
Type
number
Example
if (date1.compareTo(date2) < 0) ...

(static) date(year, month, day) → {CDate}

Set new values for this date.
Parameters:
Name Type Description
year number The year for the date.
month number The month for the date.
day number The day for the date.
Source:
Throws:
Error if an invalid date.
Returns:
The updated date.
Type
CDate
Example
date.date(2001, 1, 1)

(static) day(dayopt) → {number|CData}

Set or retrieve the day for this date.
Parameters:
Name Type Attributes Description
day number <optional>
The day for the date.
Source:
Throws:
Error if an invalid date.
Returns:
The date's day (if no parameter) or the updated date.
Type
number | CData
Example
date.day(1)
var day = date.day()

(static) dayOfWeek() → {number}

Retrieve the day of the week for this date.
Source:
Returns:
The day of the week: 0 to number of days - 1.
Type
number
Example
var dow = date.dayOfWeek()

(static) dayOfYear() → {number}

Retrieve the day of the year for this date.
Source:
Returns:
The day of the year: 1 to days per year.
Type
number
Example
var doy = date.dayOfYear()

(static) daysInMonth() → {number}

Retrieve the number of days in the month for this date.
Source:
Returns:
The number of days.
Type
number
Example
var days = date.daysInMonth()

(static) daysInYear() → {number}

Retrieve the number of days in the year for this date.
Source:
Returns:
The number of days in this year.
Type
number
Example
var days = date.daysInYear()

(static) epoch() → {string}

Retrieve the epoch designator for this date, e.g. BCE or CE.
Source:
Returns:
The current epoch.
Type
string
Example
var epoch = date.epoch()

(static) extraInfo() → {object}

Retrieve additional information about this date.
Source:
Returns:
Additional information - contents depends on calendar.
Type
object
Example
var info = date.extraInfo()

(static) formatDate(formatopt, settingsopt) → {string}

Format this date. Found in the jquery.calendars.plus.js module.
Parameters:
Name Type Attributes Description
format string <optional>
The date format to use (see formatDate).
settings object <optional>
Options for the formatDate function.
Source:
Returns:
The formatted date.
Type
string

(static) formatYear() → {string}

Format the year, if not a simple sequential number.
Source:
Returns:
The formatted year.
Type
string
Example
var year = date.formatYear()

(static) fromJD(jd) → {CDate}

Create a new date from a Julian date.
Parameters:
Name Type Description
jd number The Julian date to convert.
Source:
Returns:
The equivalent date.
Type
CDate
Example
var date2 = date1.fromJD(jd)

(static) fromJSDate(jsd) → {CDate}

Create a new date from a standard (Gregorian) JavaScript Date.
Parameters:
Name Type Description
jsd Date The JavaScript date to convert.
Source:
Returns:
The equivalent date.
Type
CDate
Example
var date2 = date1.fromJSDate(jsd)

(static) leapYear() → {boolean}

Determine whether this date is in a leap year.
Source:
Returns:
true if this is a leap year, false if not.
Type
boolean
Example
if (date.leapYear()) ...

(static) month(monthopt) → {number|CDate}

Set or retrieve the month for this date.
Parameters:
Name Type Attributes Description
month number <optional>
The month for the date.
Source:
Throws:
Error if an invalid date.
Returns:
The date's month (if no parameter) or the updated date.
Type
number | CDate
Example
date.month(1)
var month = date.month()

(static) monthOfYear() → {number}

Retrieve the month of the year for this date, i.e. the month's position within a numbered year.
Source:
Returns:
The month of the year: minMonth to months per year.
Type
number
Example
var month = date.monthOfYear()

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

Create a new date.
Parameters:
Name Type Attributes Description
year CDate | number <optional>
The date to copy or the year for the date (default to this 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).
Source:
Throws:
Error if an invalid date.
Returns:
The new date.
Type
CDate
Example
date.newDate()
date.newDate(otherDate)
date.newDate(2001, 1, 1)

(static) set(value, period) → {CDate}

Set a portion of the date.
Parameters:
Name Type Description
value number The new value for the period.
period string One of 'y' for year, 'm' for month, 'd' for day.
Source:
Throws:
Error if not a valid date.
Returns:
The updated date.
Type
CDate
Example
date.set(10, 'd')

(static) toJD() → {number}

Retrieve the Julian date equivalent for this date, i.e. days since January 1, 4713 BCE Greenwich noon.
Source:
Returns:
The equivalent Julian date.
Type
number
Example
var jd = date.toJD()

(static) toJSDate() → {Date}

Convert this date to a standard (Gregorian) JavaScript Date.
Source:
Returns:
The equivalent JavaScript date.
Type
Date
Example
var jsd = date.toJSDate()

(static) toString() → {string}

Convert to a string for display.
Source:
Returns:
This date as a string.
Type
string

(static) weekDay() → {boolean}

Determine whether this date is a week day.
Source:
Returns:
true if a week day, false if not.
Type
boolean
Example
if (date.weekDay()) ...

(static) weekOfYear() → {number}

Retrieve the week of the year for this date.
Source:
Returns:
The week of the year: 1 to weeks per year.
Type
number
Example
var week = date.weekOfYear()

(static) year(yearopt) → {number|CDate}

Set or retrieve the year for this date.
Parameters:
Name Type Attributes Description
year number <optional>
The year for the date.
Source:
Throws:
Error if an invalid date.
Returns:
The date's year (if no parameter) or the updated date.
Type
number | CDate
Example
date.year(2001)
var year = date.year()