newDate(year, month, day) |
CDate |
Create a new date object within this calendar. You can also create
dates directly
or from another date.
An error is thrown if the requested date is not valid.
year (CDate) is a date to clone or
(number) is the year for the new date.
month (number, optional) is the month for the date.
day (number, optional) is the day for the date.
var d = gc.newDate(2009, 1, 26);
var d2 = gc.newDate(d);
var d = pc.newDate(1388, 1, 1);
|
today() |
CDate |
Create a new date object representing today within this calendar.
var d = gc.today();
|
leapYear(year) |
boolean |
Determine whether or not this date is in a leap year. It returns
true if it is, or false if it is not.
You can also determine a leap year from the
date itself.
year (CDate) is a date to get the year from or
(number) is the year to examine.
if (gc.leapYear(d)) ...
if (hc.leapYear(5768)) ...
|
epoch(year) |
string |
Retrieve the epoch designator for this date. For the Gregorian calendar
this is 'BCE' for negative years or 'CE' for positive years.
You can also find the epoch from the
date itself.
year (CDate) is a date to get the year from or
(number) is the year to examine.
var e = gc.epoch(d);
var e = pc.epoch(1388);
|
formatYear(year) |
string |
Retrieve the formatted year for this date. Typically this is
the same as the normal year, padded to four digits.
For the Mayan calendar it is the long count year in the
format: baktun.katun.tun.
You can also find the formatted year from the
date itself.
year (CDate) is a date to get the year from or
(number) is the year to examine.
var fy = gc.formatYear(d);
var fy = mc.newDate(5160);
|
monthsInYear(year) |
number |
Retrieve the number of months in a given year for this calendar.
year (CDate) is a date to get the year from or
(number) is the year to examine.
var m = gc.monthsInYear(d);
var m = hc.monthsInYear(5768); // = 13
|
monthOfYear(year, month) |
number |
Retrieve the ordinal month number for a given month, i.e. the number of
the month within a numbered year as opposed to its number within the
list of months. This is only different in the Hebrew calendar
where the year numbering changes on month 7.
You can also find the month of the year from the
date itself.
The inverse function is fromMonthOfYear.
year (CDate) is a date to get the month from or
(number) is the year to exmaine.
month (number, optional) is the month to examine.
var moy = gc.monthOfYear(d);
var moy = hc.monthOfYear(5768, 7); // = 1
|
fromMonthOfYear(year, ord) |
number |
Retrieve the month for a given ordinal month number, i.e. the number of
the month within the list of months as opposed to its number within
a numbered year. This is only different in the Hebrew calendar
where the year numbering changes on month 7. The inverse function is
monthOfYear.
year (number) is the year to exmaine.
ord (number) is the ordinal month number.
var m = gc.fromMonthOfYear(y, o);
|
weekOfYear(year, month, day) |
number |
Retrieve the number of the week within the year in which a date
is located. By default this uses the ISO 8601 definition of a week:
weeks start on Monday, the first week of the year contains the first
Thursday of the year. This means that some dates at the start and end
of some years will appear in weeks from other years.
An error is thrown if the date is not valid for the calendar.
You can also find the week of the year from the
date itself.
year (CDate) is the date to examine or
(number) is the year to examine.
month (number, optional) is the month to examine.
day (number, optional) is the day to examine.
var woy = gc.weekOfYear(d);
var woy = pc.weekOfYear(1388, 1, 1);
|
daysInYear(year) |
number |
Retrieve the number of days in a given year.
You can also find the day in a year from the
date itself.
year (CDate) is a date to get the year from or
(number) is the year to examine.
var diy = gc.daysInYear(d);
var diy = hc.daysInYear(5768);
|
dayOfYear(year, month, day) |
number |
Retrieve the number of the given day within its year.
An error is thrown if the date is not valid for the calendar.
You can also find the day of the year from the
date itself.
year (CDate) is a date to examine or
(number) is the year to examine.
month (number, optional) is the month to examine.
day (number, optional) is the day to examine.
var doy = gc.dayOfYear(d);
var doy = pc.dayOfYear(1388, 1, 1);
|
daysInMonth(year, month) |
number |
Retrieve the number of days in a given month.
An error is thrown if the year or month is invalid.
You can also find the days in a month from the
date itself.
year (CDate) is a date to get the month and
year from or (number) is the year to examine.
month (number, optional) is the month to examine.
var dim = gc.daysInMonth(d);
var dim = pc.daysInMonth(1388, 12);
|
daysInWeek() |
number |
Retrieve the number of days in a week.
var diw = gc.daysInWeek();
|
dayOfWeek(year, month, day) |
number |
Retrieve the number of the given day within its week.
An error is thrown if the date is not valid for the calendar.
You can also find the day of the week from the
date itself.
year (CDate) is a date to examine or
(number) is the year to examine.
month (number, optional) is the month to examine.
day (number, optional) is the day to examine.
var dow = gc.dayOfWeek(d);
var dow = pc.dayOfWeek(1388, 1, 1);
|
weekDay(year, month, day) |
boolean |
Determine whether or not this date is a normal week day.
It returns true if it is (Monday through Friday in the
Gregorian calendar), or false if it is not.
You can also determine a week day from the
date itself.
year (CDate) is a date to examine or
(number) is the year to examine.
month (number, optional) is the month to examine.
day (number, optional) is the day to examine.
if (gc.weekDay(d)) ...
if (pc.weekDay(1388, 1, 1)) ...
|
object |
Retrieve extra information about this date - the returned
object's attributes depend on the calendar implementation.
For example, the Mayan calendar returns the corresponding
Tzolkin and Haab dates.
An error is thrown if the date is not valid for the calendar.
You can also find extra information from the
date itself.
year (CDate) is a date to examine or
(number) is the year to examine.
month (number, optional) is the month to examine.
day (number, optional) is the day to examine.
var ei = hc.extraInfo(d);
var ei = mc.extraInfo(5160, 1, 1);
alert(ei.tzolkinDayName);
|
add(date, offset, period) |
CDate |
Add a number of periods to a date and return the modified date.
If changing by month or year and the new month has fewer days,
the day is adjusted to the end of that new month.
You can also add periods to the
date itself.
date (CDate)the day to modify.
offset (number) is the amount of change; it may be negative.
period (string) is the unit of change: 'y' for years,
'm' for months, 'w' for weeks, 'd' for days.
gc.add(d, 1, 'w');
gc.add(d, 18, 'm');
|
set(date, value, period) |
CDate |
Set a period for a date.
An error is thrown if the date is not valid for the calendar.
You can also set periods for the
date itself.
date (CDate)the day to modify.
value (number) is the new period value.
period (string) is the period designator:
'y' for year, 'm' for month, 'd' for day.
gc.set(d, 2010, 'y');
pc.set(d, 1, 'm');
|
isValid(year, month, day) |
boolean |
Determine whether or not a given date is valid within this calendar.
It returns true if valid, or false if not.
year (number) is the year to examine.
month (number) is the month to examine.
day (number) is the day to examine.
if (gc.isValid(2009, 1, 26)) ... // true
if (gc.isValid(2009, 2, 29)) ... // false
|
toJD(year, month, day) |
number |
Convert a date into its Julian day number equivalent. This is the
number of days since 1 January, 4713 BCE, Greenwich noon.
An error is thrown if the date is not valid for the calendar.
You can also convert to a Julian day number from the
date itself.
year (CDate) is a date to convert or
(number) is the year to convert.
month (number, optional) is the month to convert.
day (number, optional) is the day to convert.
var jd = gc.toJD(d);
var jd = pc.toJD(1388, 1, 1);
|
fromJD(jd) |
CDate |
Create a new date for a given Julian day number.
You can also convert from a Julian day number from another
date.
jd (number) is the Julian day number to convert.
Typically it would end in .5, e.g. 2454857.5.
var d = gc.fromJD(jd);
|
toJSDate(year, month, day) |
Date |
Convert this date into the equivalent JavaScript Date.
An error is thrown if the date is not valid for the calendar.
You can also convert to a JavaScript Date from the
date itself.
year (CDate) is a date to convert or
(number) is the year to convert.
month (number, optional) is the month to convert.
day (number, optional) is the day to convert.
var jsd = gc.toJSDate(d);
var jsd = pc.toJSDate(1388, 1, 1);
|
fromJSDate(jsd) |
CDate |
Convert a JavaScript Date into the equivalent CDate.
You can also convert from a JavaScript Date from another
date.
jsd (Date) is the JavaScript date to convert.
var d = gc.fromJSDate(jsd);
var d = pc.fromJSDate(new Date(2009, 1 - 1, 26));
|