Table of Contents
JavaScript Date Object Extensions: API
Literals
The following literals are all used as the unit parameter to the add() method and the Date.addDate() function.
Date.MILLI Date.SECOND Date.MINUTE Date.HOUR Date.DAY Date.MONTH Date.YEAR
Methods
- getFullYear() Implemented only if there is no built in implementation. Returns a 4 digit year, but can't handle dates between 0 and 100 AD.
- setFullYear( year) Implemented only if there is no built in implementation. Accepts a 4 digit year but can't handle dates between 0 and 100 AD, which are interpreted as 1901 to 1999.
- compareTo( date) Similar to the standard C comparison functions, eg. returns an integer that is
> 0when this date is later than the second.0when both dates are equal.< 0when this date is earlier than the second.
- isLeapYear() returns true if this is a leap year, false otherwise.
- add( unit, amount) Adds an amount of a specific unit to this date. Units can be
Date.YEAR,Date.MONTH,Date.DAY,Date.HOUR,Date.MINUTE,Date.SECOND,Date.MILLI. - getDaysInMonth() returns the number of days in this month.
Functions
- Date.compare( d1, d2) similar to the
compareTo()method. - Date.leapYear( year) similar to the
isLeapYear()method. - Date.addDate( date, unit, amount) similar to the
add()method. - Date.daysInMonth( year, month) similar to the
getDaysInMonth()method. Parameter month must be a number from 0 to 11.
Back to Date Extensions