new BaseCalendar()
Basic functionality for all calendars.
Other calendars should extend this:
OtherCalendar.prototype = new BaseCalendar();
- Source:
Members
(static) ATOM
Date format for ATOM (RFC 3339/ISO 8601) - 'yyyy-mm-dd'.
- Source:
(static) COOKIE
Date format for cookies - 'D, dd M yyyy'.
- Source:
(static) FULL
Date format for the full date - 'DD, MM d, yyyy'.
- Source:
(static) ISO_8601
Date format for ISO 8601 - 'yyyy-mm-dd'.
- Source:
(static) JULIAN
Date format for Julian date - days since January 1, 4713 BCE Greenwich noon.
- Source:
(static) RFC_822
Date format for RFC 822 - 'D, d M yy'.
- Source:
(static) RFC_850
Date format for RFC 850 - 'DD, dd-M-yy'.
- Source:
(static) RFC_1036
Date format for RFC 1036 - 'D, d M yy'.
- Source:
(static) RFC_1123
Date format for RFC 1123 - 'D, d M yyyy'.
- Source:
(static) RFC_2822
Date format for RFC 2822 - 'D, d M yyyy'.
- Source:
(static) RSS
Date format for RSS (RFC 822) - 'D, d M yy'.
- Source:
(static) TICKS
Date format for Windows ticks - number of 100-nanosecond ticks since 1 January 0001 00:00:00 UTC.
- Source:
(static) TIMESTAMP
Date format for Unix timestamp - number of seconds elapsed since the
start of the Unix epoch at 1 January 1970 00:00:00 UTC.
- Source:
(static) W3C
Date format for W3C (ISO 8601) - 'yyyy-mm-dd'.
- Source:
Methods
(static) add(date, offset, period) → {CDate}
Add period(s) to a date.
Cater for no year zero.
Parameters:
Name | Type | Description |
---|---|---|
date |
CDate | The starting date. |
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:
Throws:
Error if a different calendar is used.
Returns:
The updated date.
- Type
- CDate
Example
calendar.add(date, 10, 'd')
(static) dayOfWeek(year, monthopt, dayopt) → {number}
Retrieve the day of the week for a date.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to examine or the year to examine. | |
month |
number |
<optional> |
The month to examine (if numeric year specified above). |
day |
number |
<optional> |
The day to examine (if numeric year specified above). |
- Source:
Throws:
Error if an invalid date or a different calendar is used.
Returns:
The day of the week: 0 to number of days - 1.
- Type
- number
Example
var dow = calendar.dayOfWeek(date)
var dow = calendar.dayOfWeek(2014, 1, 26)
(static) dayOfYear(year, monthopt, dayopt) → {number}
Retrieve the day of the year for a date.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to convert or the year to convert. | |
month |
number |
<optional> |
The month to convert (if numeric year specified above). |
day |
number |
<optional> |
The day to convert (if numeric year specified above). |
- Source:
Throws:
Error if an invalid date or a different calendar is used.
Returns:
The day of the year: 1 to days per year.
- Type
- number
Example
var doy = calendar.dayOfYear(date)
var doy = calendar.dayOfYear(2014, 7, 1)
(static) daysInWeek() → {number}
Retrieve the number of days in a week.
- Source:
Returns:
The number of days.
- Type
- number
Example
var days = calendar.daysInWeek()
(static) daysInYear(year) → {number}
Retrieve the number of days in a year.
Parameters:
Name | Type | Description |
---|---|---|
year |
CDate | number | The date to examine or the year to examine. |
- Source:
Throws:
Error if an invalid year or a different calendar is used.
Returns:
The number of days.
- Type
- number
Example
var days = calendar.daysInYear(date)
var days = calendar.daysInYear(2014)
(static) determineDate(dateSpec, defaultDate, currentDateopt, dateFormatopt, settingsopt) → {CDate}
A date may be specified as an exact value or a relative one.
Found in the
jquery.calendars.plus.js
module.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dateSpec |
CDate | number | string | The date as an object or string in the given format or an offset - numeric days from today, or string amounts and periods, e.g. '+1m +2w'. | ||||||||||||||||||||||||||
defaultDate |
CDate | The date to use if no other supplied, may be null . |
||||||||||||||||||||||||||
currentDate |
CDate |
<optional> |
null | The current date as a possible basis for relative dates,
if null today is used. |
||||||||||||||||||||||||
dateFormat |
string |
<optional> |
The expected date format -
see formatDate . Use '' for the calendar default format. |
|||||||||||||||||||||||||
settings |
object |
<optional> |
Additional options whose attributes include:
Properties
|
- Source:
Returns:
The decoded date.
- Type
- CDate
(static) epoch(year) → {string}
Retrieve the epoch designator for this date.
Parameters:
Name | Type | Description |
---|---|---|
year |
CDate | number | The date to examine or the year to examine. |
- Source:
Throws:
Error if an invalid year or a different calendar is used.
Returns:
The current epoch.
- Type
- string
Example
var epoch = calendar.epoch(date)
var epoch = calendar.epoch(2014)
(static) extraInfo(year, monthopt, dayopt) → {object}
Retrieve additional information about a date.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to examine or the year to examine. | |
month |
number |
<optional> |
The month to examine (if numeric year specified above). |
day |
number |
<optional> |
The day to examine (if numeric year specified above). |
- Source:
Throws:
Error if an invalid date or a different calendar is used.
Returns:
Additional information - content depends on calendar.
- Type
- object
Example
var info = calendar.extraInfo(date)
var info = calendar.extraInfo(2014, 1, 26)
(static) formatDate(formatopt, date, settingsopt) → {string}
Format a date object into a string value.
The format can be combinations of the following:
- d - day of month (no leading zero)
- dd - day of month (two digit)
- o - day of year (no leading zeros)
- oo - day of year (three digit)
- D - day name short
- DD - day name long
- w - week of year (no leading zero)
- ww - week of year (two digit)
- m - month of year (no leading zero)
- mm - month of year (two digit)
- M - month name short
- MM - month name long
- yy - year (two digit)
- yyyy - year (four digit)
- YYYY - formatted year
- J - Julian date (days since January 1, 4713 BCE Greenwich noon)
- @ - Unix timestamp (s since 01/01/1970)
- ! - Windows ticks (100ns since 01/01/0001)
- '...' - literal text
- '' - single quote
jquery.calendars.plus.js
module.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
format |
string |
<optional> |
The desired format of the date (defaults to calendar format). | ||||||||||||||||||||||||||||||
date |
CDate | The date value to format. | |||||||||||||||||||||||||||||||
settings |
object |
<optional> |
Addition options, whose attributes include:
Properties
|
- Source:
Throws:
Errors if the date is from a different calendar.
Returns:
The date in the above format.
- Type
- string
(static) formatYear(year) → {string}
Format the year, if not a simple sequential number
Parameters:
Name | Type | Description |
---|---|---|
year |
CDate | number | The date to format or the year to format. |
- Source:
Throws:
Error if an invalid year or a different calendar is used.
Returns:
The formatted year.
- Type
- string
Example
var year = calendar.formatYear(date)
var year = calendar.formatYear(2014)
(static) fromJSDate(jsd) → {CDate}
Convert the date from a standard (Gregorian) JavaScript Date.
Parameters:
Name | Type | Description |
---|---|---|
jsd |
Date | The JavaScript date. |
- Source:
Returns:
The equivalent calendar date.
- Type
- CDate
Example
var date = calendar.fromJSDate(jsd)
(static) fromMonthOfYear(year, ord) → {number}
Calculate actual month from ordinal position, starting from
minMonth
.
Parameters:
Name | Type | Description |
---|---|---|
year |
number | The year to examine. |
ord |
number | The month's ordinal position. |
- Source:
Throws:
Error if an invalid year/month.
Returns:
The month's number.
- Type
- number
Example
var month = calendar.fromMonthOfYear(2014, 7)
(static) isValid(year, month, day) → {boolean}
Determine whether a date is valid for this calendar.
Parameters:
Name | Type | Description |
---|---|---|
year |
number | The year to examine. |
month |
number | The month to examine. |
day |
number | The day to examine. |
- Source:
Returns:
true
if a valid date, false
if not.
- Type
- boolean
Example
if (calendar.isValid(2014, 2, 31)) ...
(static) monthOfYear(year, monthopt) → {number}
Calculate the month's ordinal position within the year -
for those calendars that don't start at month 1!
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to examine or the year to examine. | |
month |
number |
<optional> |
The month to examine (if numeric year specified above). |
- Source:
Throws:
Error if an invalid year/month or a different calendar is used.
Returns:
The ordinal position, starting from
minMonth
.
- Type
- number
Example
var pos = calendar.monthOfYear(date)
var pos = calendar.monthOfYear(2014, 7)
(static) monthsInYear(year) → {number}
Retrieve the number of months in a year.
Parameters:
Name | Type | Description |
---|---|---|
year |
CDate | number | The date to examine or the year to examine. |
- Source:
Throws:
Error if an invalid year or a different calendar is used.
Returns:
The number of months.
- Type
- number
Example
var months = calendar.monthsInYear(date)
var months = calendar.monthsInYear(2014)
(static) newDate(year, monthopt, dayopt) → {CDate}
Create a new date within this calendar - today if no parameters given.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to duplicate 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). |
- Source:
Throws:
Error if not a valid date or a different calendar is used.
Returns:
The new date.
- Type
- CDate
Example
var date = calendar.newDate(2014, 1, 26)
var date2 = calendar.newDate(date1)
var today = calendar.newDate()
(static) parseDate(format, value, settingsopt) → {CDate}
Parse a string value into a date object.
See
formatDate
for the possible formats, plus:
- * - ignore rest of string
jquery.calendars.plus.js
module.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
format |
string | The expected format of the date ('' for default calendar format). | |||||||||||||||||||||||||
value |
string | The date in the above format. | |||||||||||||||||||||||||
settings |
object |
<optional> |
Additional options whose attributes include:
Properties
|
- Source:
Throws:
Errors if the format and/or value are missing,
if the value doesn't match the format, or if the date is invalid.
Returns:
The extracted date value or
null
if value is blank.
- Type
- CDate
(static) set(date, value, period) → {CDate}
Set a portion of the date.
Parameters:
Name | Type | Description |
---|---|---|
date |
CDate | The starting date. |
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 an invalid date or a different calendar is used.
Returns:
The updated date.
- Type
- CDate
Example
calendar.set(date, 10, 'd')
(static) today() → {CDate}
Create a new date for today.
- Source:
Returns:
Today's date.
- Type
- CDate
Example
var today = calendar.today()
(static) toJSDate(year, monthopt, dayopt) → {Date}
Convert the date to a standard (Gregorian) JavaScript Date.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
year |
CDate | number | The date to convert or the year to convert. | |
month |
number |
<optional> |
The month to convert (if numeric year specified above). |
day |
number |
<optional> |
The day to convert (if numeric year specified above). |
- Source:
Throws:
Error if an invalid date or a different calendar is used.
Returns:
The equivalent JavaScript date.
- Type
- Date
Example
var jsd = calendar.toJSDate(date)
var jsd = calendar.toJSDate(2014, 1, 26)