Yahoo! UI Library

Calendar  2.3.0

Yahoo! UI Library > calendar > YAHOO.widget.DateMath

Show Private Show Protected

Class YAHOO.widget.DateMath

YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility used for adding, subtracting, and comparing dates.

Properties

DAY - static final String

Constant field representing Day

MONTH - static final String

Constant field representing Month

ONE_DAY_MS - static final Number

Constant field representing one day, in milliseconds

WEEK - static final String

Constant field representing Week

YEAR - static final String

Constant field representing Year

Methods

add

Date add ( date , field , amount )
Adds the specified amount of time to the this instance.
Parameters:
date <Date> The JavaScript Date object to perform addition on
field <String> The field constant to be used for performing addition.
amount <Number> The number of units (measured in the field constant) to add to the date.
Returns: Date
The resulting Date object

after

Boolean after ( date , compareTo )
Determines whether a given date is after another date on the calendar.
Parameters:
date <Date> The Date object to compare with the compare argument
compareTo <Date> The Date object to use for the comparison
Returns: Boolean
true if the date occurs after the compared date; false if not.

before

Boolean before ( date , compareTo )
Determines whether a given date is before another date on the calendar.
Parameters:
date <Date> The Date object to compare with the compare argument
compareTo <Date> The Date object to use for the comparison
Returns: Boolean
true if the date occurs before the compared date; false if not.

between

Boolean between ( date , dateBegin , dateEnd )
Determines whether a given date is between two other dates on the calendar.
Parameters:
date <Date> The date to check for
dateBegin <Date> The start of the range
dateEnd <Date> The end of the range
Returns: Boolean
true if the date occurs between the compared dates; false if not.

clearTime

Date clearTime ( date )
Clears the time fields from a given date, effectively setting the time to 12 noon.
Parameters:
date <Date> The JavaScript Date for which the time fields will be cleared
Returns: Date
The JavaScript Date cleared of all time fields

findMonthEnd

Date findMonthEnd ( date )
Gets the last day of a month containing a given date.
Parameters:
date <Date> The JavaScript Date used to calculate the month end
Returns: Date
The JavaScript Date representing the last day of the month

findMonthStart

Date findMonthStart ( date )
Gets the first day of a month containing a given date.
Parameters:
date <Date> The JavaScript Date used to calculate the month start
Returns: Date
The JavaScript Date representing the first day of the month

getDayOffset

Number getDayOffset ( date , calendarYear )
Calculates the number of days the specified date is from January 1 of the specified calendar year. Passing January 1 to this function would return an offset value of zero.
Parameters:
date <Date> The JavaScript date for which to find the offset
calendarYear <Number> The calendar year to use for determining the offset
Returns: Number
The number of days since January 1 of the given year

getJan1

Date getJan1 ( calendarYear )
Retrieves a JavaScript Date object representing January 1 of any given year.
Parameters:
calendarYear <Number> The calendar year for which to retrieve January 1
Returns: Date
January 1 of the calendar year specified.

getWeekNumber

Number getWeekNumber ( date , calendarYear )
Calculates the week number for the given date. This function assumes that week 1 is the week in which January 1 appears, regardless of whether the week consists of a full 7 days. The calendar year can be specified to help find what a the week number would be for a given date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction easily.
Parameters:
date <Date> The JavaScript date for which to find the week number
calendarYear <Number> OPTIONAL - The calendar year to use for determining the week number. Default is the calendar year of parameter "date".
Returns: Number
The week number of the given date.

isMonthOverlapWeek

Boolean isMonthOverlapWeek ( weekBeginDate )
Determines if a given week overlaps two different months.
Parameters:
weekBeginDate <Date> The JavaScript Date representing the first day of the week.
Returns: Boolean
true if the date overlaps two different months.

isYearOverlapWeek

Boolean isYearOverlapWeek ( weekBeginDate )
Determines if a given week overlaps two different years.
Parameters:
weekBeginDate <Date> The JavaScript Date representing the first day of the week.
Returns: Boolean
true if the date overlaps two different years.

subtract

Date subtract ( date , field , amount )
Subtracts the specified amount of time from the this instance.
Parameters:
date <Date> The JavaScript Date object to perform subtraction on
field <Number> The this field constant to be used for performing subtraction.
amount <Number> The number of units (measured in the field constant) to subtract from the date.
Returns: Date
The resulting Date object


Copyright © 2007 Yahoo! Inc. All rights reserved.