Print Friendly

Class YAHOO.widget.DateMath

Package:YAHOO.widget
Class:DateMath
Extends:Object
Defined In:calendar.js
YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility used for adding, subtracting, and comparing dates.

Public Properties

Property Defined By
  CSS_CALENDAR : Object DateMath
  CSS_CELL : Object DateMath
  CSS_CELL_BOTTOM : Object DateMath
  CSS_CELL_HIGHLIGHT1 : Object DateMath
  CSS_CELL_HIGHLIGHT2 : Object DateMath
  CSS_CELL_HIGHLIGHT3 : Object DateMath
  CSS_CELL_HIGHLIGHT4 : Object DateMath
  CSS_CELL_HOVER : Object DateMath
  CSS_CELL_LEFT : Object DateMath
  CSS_CELL_OOB : Object DateMath
  CSS_CELL_OOM : Object DateMath
  CSS_CELL_RESTRICTED : Object DateMath
  CSS_CELL_RIGHT : Object DateMath
  CSS_CELL_SELECTABLE : Object DateMath
  CSS_CELL_SELECTED : Object DateMath
  CSS_CELL_TODAY : Object DateMath
  CSS_CELL_TOP : Object DateMath
  CSS_CONTAINER : Object DateMath
  CSS_FOOTER : Object DateMath
  CSS_HEADER : Object DateMath
  CSS_HEADER_TEXT : Object DateMath
  CSS_NAV_LEFT : Object DateMath
  CSS_NAV_RIGHT : Object DateMath
  CSS_ROW_FOOTER : Object DateMath
  CSS_ROW_HEADER : Object DateMath
  CSS_SINGLE : Object DateMath
  CSS_WEEKDAY_CELL : Object DateMath
  CSS_WEEKDAY_ROW : Object DateMath
  DATE<static> : String DateMath
<static> Type constant used for renderers to represent an individual date (M/D/Y)
  DAY : String DateMath
<static> Constant field representing Day
  DISPLAY_DAYS<static> : Number DateMath
<static> Constant that represents the total number of date cells that are displayed in a given month
  Locale : Object DateMath
The local object which contains the Calendar's locale settings
  MONTH : String DateMath
<static> Constant field representing Month
  MONTH<static> : String DateMath
<static> Type constant used for renderers to represent a month across any year
  MONTH_DAY<static> : String DateMath
<static> Type constant used for renderers to represent an individual date across any year (M/D)
  ONE_DAY_MS : Number DateMath
<static> Constant field representing one day, in milliseconds
  Options : Object DateMath
The local object which contains the Calendar's options
  RANGE<static> : String DateMath
<static> Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
  STOP_RENDER<static> : String DateMath
<static> Constant used for halting the execution of the remainder of the render stack
  Style : Object DateMath
Collection of Style constants for the Calendar
  WEEK : String DateMath
<static> Constant field representing Week
  WEEKDAY<static> : String DateMath
<static> Type constant used for renderers to represent a weekday
  YEAR : String DateMath
<static> Constant field representing Year
  browser : String DateMath
Returns a string representing the current browser.
  cellDates : Array[](Number[]) DateMath
The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays...
  cells : HTMLTableCellElement[] DateMath
The collection of calendar table cells
  cfg : Number @default DateMath
The position of the year in a month/day/year date string @config MDY_YEAR_POSITION
  domEventMap : Object DateMath
A map of DOM event handlers to attach to cells associated with specific CSS class names
  https : String DateMath
<static> The path to be used for images loaded for the Calendar
  id : String DateMath
The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
  index : Number DateMath
The index of this item in the parent group
  oDomContainer : HTMLElement DateMath
The DOM element reference that points to this calendar's container element. The calendar will be inserted into this e...
  parent : CalendarGroup DateMath
The parent CalendarGroup, only to be set explicitly by the parent group
  renderStack : Array[] DateMath
The list of render functions, along with required parameters, used to render cells.
  today : Date DateMath
A Date object representing today's date.

Public Methods

Method Defined By
  add(Date date, String field, Number amount) : Date DateMath
Adds the specified amount of time to the this instance.
  addMonthRenderer(Number month, Function fnRender) : void DateMath
Adds a month to the render stack. The function reference passed to this method will be executed when a date cell matc...
  addMonths(Number count) : void DateMath
Adds the designated number of months to the current calendar month, and sets the current calendar page date to the ne...
  addRenderer(String sDates, Function fnRender) : void DateMath
Adds a renderer to the render stack. The function reference passed to this method will be executed when a date cell m...
  addWeekdayRenderer(Number weekday, Function fnRender) : void DateMath
Adds a weekday to the render stack. The function reference passed to this method will be executed when a date cell ma...
  addYears(Number count) : void DateMath
Adds the designated number of years to the current calendar, and sets the current calendar page date to the new month.
  after(Date date, Date compareTo) : Boolean DateMath
Determines whether a given date is after another date on the calendar.
  applyListeners() : void DateMath
Applies the Calendar's DOM listeners to applicable elements.
  before(Date date, Date compareTo) : Boolean DateMath
Determines whether a given date is before another date on the calendar.
  between(Date date, Date dateBegin, Date dateEnd) : Boolean DateMath
Determines whether a given date is between two other dates on the calendar.
  buildDayLabel(Date workingDate) : String DateMath
Builds the date digit that will be displayed in calendar cells
  buildMonthLabel() : String DateMath
Builds the date label that will be displayed in the calendar header or footer, depending on configuration.
  buildWeekdays(Array html) : Array DateMath
Renders the Calendar's weekday headers.
  clear() : void DateMath
Clears the selected dates in the current calendar widget and sets the calendar to the current month and year.
  clearAllBodyCellStyles(style The) : void DateMath
Removes all styles from all body cells in the current calendar table.
  clearElement(HTMLTableCellElement The) : void DateMath
Clears the inner HTML, CSS class and style information from the specified cell.
  clearTime(Date date) : Date DateMath
Clears the time fields from a given date, effectively setting the time to midnight.
  configClose() : void DateMath
Default handler for the "close" property
  configIframe() : void DateMath
Renders the built-in IFRAME shim for the IE6 and below
  configLocale() : void DateMath
The default handler for all configuration locale properties
  configLocaleValues() : void DateMath
The default handler for all configuration locale field length properties
  configMaxDate() : void DateMath
The default handler for the "maxdate" property
  configMinDate() : void DateMath
The default handler for the "mindate" property
  configOptions() : void DateMath
The default handler for all configuration options properties
  configPageDate() : void DateMath
The default handler for the "pagedate" property
  configSelected() : void DateMath
The default handler for the "selected" property
  configTitle() : void DateMath
Default handler for the "title" property
  deselect(String/Date/Date[] date) : Date[] DateMath
Deselects a date or a collection of dates on the current calendar. This method, by default, does not call the render ...
  deselectAll() : Date[] DateMath
Deselects all dates on the current calendar.
  deselectCell(Number cellIndex) : Date[] DateMath
Deselects a date on the current calendar by referencing the index of the cell that should be deselected. This method ...
  doCellMouseOut(DOMEvent e, Calendar cal) : void DateMath
The event that is executed when the user moves the mouse out of a cell
  doCellMouseOver(DOMEvent e, Calendar cal) : void DateMath
The event that is executed when the user hovers over a cell
  doSelectCell(DOMEvent e, Calendar cal) : void DateMath
The default event function that is attached to a date link within a calendar cell when the calendar is rendered.
  findMonthEnd(Date date) : Date DateMath
Gets the last day of a month containing a given date.
  findMonthStart(Date date) : Date DateMath
Gets the first day of a month containing a given date.
  getDateByCellId(String id) : Date DateMath
Retrieves the Date object for the specified Calendar cell
  getDateFieldsByCellId(String id) : Array DateMath
Retrieves the Date object for the specified Calendar cell
  getDayOffset(Date date, Number calendarYear) : Number DateMath
Calculates the number of days the specified date is from January 1 of the specified calendar year. Passing January 1 ...
  getJan1(Number calendarYear) : Date DateMath
Retrieves a JavaScript Date object representing January 1 of any given year.
  getSelectedDates() : Date[] DateMath
Gets the list of currently selected dates from the calendar.
  getWeekNumber(Date date, Number calendarYear, Number weekStartsOn) : Number DateMath
Calculates the week number for the given date. This function assumes that week 1 is the week in which January 1 appea...
  hide() : void DateMath
Hides the Calendar's outer container from view.
  init(String id, String containerId, Object config) : void DateMath
Initializes the Calendar widget.
  initEvents() : void DateMath
Initializes Calendar's built-in CustomEvents
  initStyles() : void DateMath
Defines the style constants for the Calendar
  isDateOOM(Date date) : Boolean DateMath
Determines whether a given date is OOM (out of month).
  isMonthOverlapWeek(Date weekBeginDate) : Boolean DateMath
Determines if a given week overlaps two different months.
  isYearOverlapWeek(Date weekBeginDate) : Boolean DateMath
Determines if a given week overlaps two different years.
  nextMonth() : void DateMath
Navigates to the next month page in the calendar widget.
  nextYear() : void DateMath
Navigates to the next year in the currently selected month in the calendar widget.
  onBeforeDeselect() : void DateMath
Deprecated. Event executed before a date is deselected in the calendar widget.
  onBeforeSelect() : void DateMath
Deprecated. Event executed before a date is selected in the calendar widget.
  onChangePage() : void DateMath
Deprecated. Event executed when the user navigates to a different calendar page.
  onDeselect(Array selected) : void DateMath
Deprecated. Event executed when a date is deselected in the calendar widget.
  onRender() : void DateMath
Deprecated. Event executed when the calendar widget is rendered.
  onSelect(Array selected) : void DateMath
Deprecated. Event executed when a date is selected in the calendar widget.
  previousMonth() : void DateMath
Navigates to the previous month page in the calendar widget.
  previousYear() : void DateMath
Navigates to the previous year in the currently selected month in the calendar widget.
  render() : void DateMath
Deprecated. Event executed when the calendar widget is completely cleared to the current month with no selections.
  renderBody(Date workingDate, Array html) : Array DateMath
Renders the calendar body.
  renderBodyCellRestricted(Date workingDate, HTMLTableCellElement cell) : String DateMath
Renders the current calendar cell as a non-selectable "black-out" date using the default restricted style.
  renderCellDefault(Date workingDate, HTMLTableCellElement cell) : void DateMath
Renders a single standard calendar cell in the calendar widget table. All logic for determining how a standard defaul...
  renderCellNotThisMonth(Date workingDate, HTMLTableCellElement cell) : String DateMath
Applies the default style used for rendering dates that are not a part of the current month (preceding or trailing th...
  renderCellStyleHighlight1(Date workingDate, HTMLTableCellElement cell) : void DateMath
Renders a single standard calendar cell using the CSS hightlight1 style
  renderCellStyleHighlight2(Date workingDate, HTMLTableCellElement cell) : void DateMath
Renders a single standard calendar cell using the CSS hightlight2 style
  renderCellStyleHighlight3(Date workingDate, HTMLTableCellElement cell) : void DateMath
Renders a single standard calendar cell using the CSS hightlight3 style
  renderCellStyleHighlight4(Date workingDate, HTMLTableCellElement cell) : void DateMath
Renders a single standard calendar cell using the CSS hightlight4 style
  renderCellStyleSelected(Date workingDate, HTMLTableCellElement cell) : String DateMath
Applies the default style used for rendering selected dates to the current calendar cell
  renderCellStyleToday(Date workingDate, HTMLTableCellElement cell) : void DateMath
Applies the default style used for rendering today's date to the current calendar cell
  renderFooter(Array html) : Array DateMath
Renders the calendar footer. In the default implementation, there is no footer.
  renderHeader(Array html) : Array DateMath
Renders the calendar header.
  renderOutOfBoundsDate(Date workingDate, HTMLTableCellElement cell) : String DateMath
Renders a cell that falls before the minimum date or after the maximum date. widget class.
  renderRowFooter(Number weekNum, Array cell) : void DateMath
Renders the row footer for a week.
  renderRowHeader(Number weekNum, Array cell) : void DateMath
Renders the row header for a week.
  reset() : void DateMath
Resets the calendar widget to the originally selected month and year, and sets the calendar to the initial selection(s).
  resetRenderers() : void DateMath
Resets the render stack of the current calendar to its original pre-render value.
  select(String/Date/Date[] date) : Date[] DateMath
Selects a date or a collection of dates on the current calendar. This method, by default, does not call the render me...
  selectCell(Number cellIndex) : Date[] DateMath
Selects a date on the current calendar by referencing the index of the cell that should be selected. This method is u...
  setMonth(Number month) : void DateMath
Sets the calendar's month explicitly
  setYear(Number year) : void DateMath
Sets the calendar's year explicitly.
  show() : void DateMath
Shows the Calendar's outer container.
  styleCellDefault(Date workingDate, HTMLTableCellElement cell) : void DateMath
Styles a selectable cell.
  subtract(Date date, Number field, Number amount) : Date DateMath
Subtracts the specified amount of time from the this instance.
  subtractMonths(Number count) : void DateMath
Subtracts the designated number of months from the current calendar month, and sets the current calendar page date to...
  subtractYears(Number count) : void DateMath
Subtcats the designated number of years from the current calendar, and sets the current calendar page date to the new...
  toString() : String DateMath
Returns a string representation of the object.
  validate() : Should DateMath
Validates the calendar widget. This method has no default implementation and must be extended by subclassing the widget.

Public Events

Event Defined By
  beforeDeselectEvent : () DateMath
Fired before a selection is made
  beforeRenderEvent : () DateMath
Fired before the Calendar is rendered
  beforeSelectEvent : () DateMath
Fired before a selection is made
  changePageEvent : () DateMath
Fired when the Calendar page is changed
  clearEvent : () DateMath
Fired when the Calendar is cleared
  deselectEvent : (Array Array) DateMath
Fired when a selection is made
  renderEvent : () DateMath
Fired when the Calendar is rendered
  resetEvent : () DateMath
Fired when the Calendar is reset
  selectEvent : (Array Array) DateMath
Fired when a selection is made

Property Details

CSS_CALENDAR

public Object CSS_CALENDAR
This property is defined by DateMath.

CSS_CELL

public Object CSS_CELL
This property is defined by DateMath.

CSS_CELL_BOTTOM

public Object CSS_CELL_BOTTOM
This property is defined by DateMath.

CSS_CELL_HIGHLIGHT1

public Object CSS_CELL_HIGHLIGHT1
This property is defined by DateMath.

CSS_CELL_HIGHLIGHT2

public Object CSS_CELL_HIGHLIGHT2
This property is defined by DateMath.

CSS_CELL_HIGHLIGHT3

public Object CSS_CELL_HIGHLIGHT3
This property is defined by DateMath.

CSS_CELL_HIGHLIGHT4

public Object CSS_CELL_HIGHLIGHT4
This property is defined by DateMath.

CSS_CELL_HOVER

public Object CSS_CELL_HOVER
This property is defined by DateMath.

CSS_CELL_LEFT

public Object CSS_CELL_LEFT
This property is defined by DateMath.

CSS_CELL_OOB

public Object CSS_CELL_OOB
This property is defined by DateMath.

CSS_CELL_OOM

public Object CSS_CELL_OOM
This property is defined by DateMath.

CSS_CELL_RESTRICTED

public Object CSS_CELL_RESTRICTED
This property is defined by DateMath.

CSS_CELL_RIGHT

public Object CSS_CELL_RIGHT
This property is defined by DateMath.

CSS_CELL_SELECTABLE

public Object CSS_CELL_SELECTABLE
This property is defined by DateMath.

CSS_CELL_SELECTED

public Object CSS_CELL_SELECTED
This property is defined by DateMath.

CSS_CELL_TODAY

public Object CSS_CELL_TODAY
This property is defined by DateMath.

CSS_CELL_TOP

public Object CSS_CELL_TOP
This property is defined by DateMath.

CSS_CONTAINER

public Object CSS_CONTAINER
This property is defined by DateMath.

CSS_FOOTER

public Object CSS_FOOTER
This property is defined by DateMath.

CSS_HEADER

public Object CSS_HEADER
This property is defined by DateMath.

CSS_HEADER_TEXT

public Object CSS_HEADER_TEXT
This property is defined by DateMath.

CSS_NAV_LEFT

public Object CSS_NAV_LEFT
This property is defined by DateMath.

CSS_NAV_RIGHT

public Object CSS_NAV_RIGHT
This property is defined by DateMath.

CSS_ROW_FOOTER

public Object CSS_ROW_FOOTER
This property is defined by DateMath.

CSS_ROW_HEADER

public Object CSS_ROW_HEADER
This property is defined by DateMath.

CSS_SINGLE

public Object CSS_SINGLE
This property is defined by DateMath.

CSS_WEEKDAY_CELL

public Object CSS_WEEKDAY_CELL
This property is defined by DateMath.

CSS_WEEKDAY_ROW

public Object CSS_WEEKDAY_ROW
This property is defined by DateMath.

DATE<static>

public String DATE<static>
<static> Type constant used for renderers to represent an individual date (M/D/Y)
This property is defined by DateMath.

DAY

public String DAY
<static> Constant field representing Day
This property is defined by DateMath.

DISPLAY_DAYS<static>

public Number DISPLAY_DAYS<static>
<static> Constant that represents the total number of date cells that are displayed in a given month
This property is defined by DateMath.

Locale

public Object Locale
The local object which contains the Calendar's locale settings
This property is defined by DateMath.

MONTH

public String MONTH
<static> Constant field representing Month
This property is defined by DateMath.

MONTH<static>

public String MONTH<static>
<static> Type constant used for renderers to represent a month across any year
This property is defined by DateMath.

MONTH_DAY<static>

public String MONTH_DAY<static>
<static> Type constant used for renderers to represent an individual date across any year (M/D)
This property is defined by DateMath.

ONE_DAY_MS

public Number ONE_DAY_MS
<static> Constant field representing one day, in milliseconds
This property is defined by DateMath.

Options

public Object Options
The local object which contains the Calendar's options
This property is defined by DateMath.

RANGE<static>

public String RANGE<static>
<static> Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
This property is defined by DateMath.

STOP_RENDER<static>

public String STOP_RENDER<static>
<static> Constant used for halting the execution of the remainder of the render stack
This property is defined by DateMath.

Style

public Object Style
Collection of Style constants for the Calendar
This property is defined by DateMath.

WEEK

public String WEEK
<static> Constant field representing Week
This property is defined by DateMath.

WEEKDAY<static>

public String WEEKDAY<static>
<static> Type constant used for renderers to represent a weekday
This property is defined by DateMath.

YEAR

public String YEAR
<static> Constant field representing Year
This property is defined by DateMath.

browser

public String browser
Returns a string representing the current browser.
This property is defined by DateMath.

cellDates

public Array[](Number[]) cellDates
The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
This property is defined by DateMath.

cells

public HTMLTableCellElement[] cells
The collection of calendar table cells
This property is defined by DateMath.

cfg

public Number @default cfg
The position of the year in a month/day/year date string @config MDY_YEAR_POSITION
This property is defined by DateMath.

domEventMap

public Object domEventMap
A map of DOM event handlers to attach to cells associated with specific CSS class names
This property is defined by DateMath.

https

public String https
<static> The path to be used for images loaded for the Calendar
This property is defined by DateMath.

id

public String id
The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
This property is defined by DateMath.

index

public Number index
The index of this item in the parent group
This property is defined by DateMath.

oDomContainer

public HTMLElement oDomContainer
The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
This property is defined by DateMath.

parent

public CalendarGroup parent
The parent CalendarGroup, only to be set explicitly by the parent group
This property is defined by DateMath.

renderStack

public Array[] renderStack
The list of render functions, along with required parameters, used to render cells.
This property is defined by DateMath.

today

public Date today
A Date object representing today's date.
This property is defined by DateMath.

Method Details

add

public function add(Date date, String field, Number 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
This method is defined by DateMath.

addMonthRenderer

public function addMonthRenderer(Number month, Function fnRender)
Adds a month to the render stack. The function reference passed to this method will be executed when a date cell matches the month passed to this method.
Parameters:
  • month : Number
    The month (1-12) to associate with this renderer
  • fnRender : Function
    The function executed to render cells that match the render rules for this renderer.
Returns:
  • void
This method is defined by DateMath.

addMonths

public function addMonths(Number count)
Adds the designated number of months to the current calendar month, and sets the current calendar page date to the new month.
Parameters:
  • count : Number
    The number of months to add to the current calendar
Returns:
  • void
This method is defined by DateMath.

addRenderer

public function addRenderer(String sDates, Function fnRender)
Adds a renderer to the render stack. The function reference passed to this method will be executed when a date cell matches the conditions specified in the date string for this renderer.
Parameters:
  • sDates : String
    A date string to associate with the specified renderer. Valid formats include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
  • fnRender : Function
    The function executed to render cells that match the render rules for this renderer.
Returns:
  • void
This method is defined by DateMath.

addWeekdayRenderer

public function addWeekdayRenderer(Number weekday, Function fnRender)
Adds a weekday to the render stack. The function reference passed to this method will be executed when a date cell matches the weekday passed to this method.
Parameters:
  • weekday : Number
    The weekday (0-6) to associate with this renderer
  • fnRender : Function
    The function executed to render cells that match the render rules for this renderer.
Returns:
  • void
This method is defined by DateMath.

addYears

public function addYears(Number count)
Adds the designated number of years to the current calendar, and sets the current calendar page date to the new month.
Parameters:
  • count : Number
    The number of years to add to the current calendar
Returns:
  • void
This method is defined by DateMath.

after

public function after(Date date, 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.
This method is defined by DateMath.

applyListeners

public function applyListeners()
Applies the Calendar's DOM listeners to applicable elements.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

before

public function before(Date date, 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.
This method is defined by DateMath.

between

public function between(Date date, Date dateBegin, Date 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.
This method is defined by DateMath.

buildDayLabel

public function buildDayLabel(Date workingDate)
Builds the date digit that will be displayed in calendar cells
Parameters:
  • workingDate : Date
    The current working date
Returns:
  • String
    The formatted day label
This method is defined by DateMath.

buildMonthLabel

public function buildMonthLabel()
Builds the date label that will be displayed in the calendar header or footer, depending on configuration.
Parameters:
  • None.
Returns:
  • String
    The formatted calendar month label
This method is defined by DateMath.

buildWeekdays

public function buildWeekdays(Array html)
Renders the Calendar's weekday headers.
Parameters:
  • html : Array
    The current working HTML array
Returns:
  • Array
    The current working HTML array
This method is defined by DateMath.

clear

public function clear()
Clears the selected dates in the current calendar widget and sets the calendar to the current month and year.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

clearAllBodyCellStyles

public function clearAllBodyCellStyles(style The)
Removes all styles from all body cells in the current calendar table.
Parameters:
  • The : style
    CSS class name to remove from all calendar body cells
Returns:
  • void
This method is defined by DateMath.

clearElement

public function clearElement(HTMLTableCellElement The)
Clears the inner HTML, CSS class and style information from the specified cell.
Parameters:
  • The : HTMLTableCellElement
    cell to clear
Returns:
  • void
This method is defined by DateMath.

clearTime

public function clearTime(Date date)
Clears the time fields from a given date, effectively setting the time to midnight.
Parameters:
  • date : Date
    The JavaScript Date for which the time fields will be cleared
Returns:
  • Date
    The JavaScript Date cleared of all time fields
This method is defined by DateMath.

configClose

public function configClose()
Default handler for the "close" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configIframe

public function configIframe()
Renders the built-in IFRAME shim for the IE6 and below
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configLocale

public function configLocale()
The default handler for all configuration locale properties
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configLocaleValues

public function configLocaleValues()
The default handler for all configuration locale field length properties
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configMaxDate

public function configMaxDate()
The default handler for the "maxdate" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configMinDate

public function configMinDate()
The default handler for the "mindate" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configOptions

public function configOptions()
The default handler for all configuration options properties
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configPageDate

public function configPageDate()
The default handler for the "pagedate" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configSelected

public function configSelected()
The default handler for the "selected" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

configTitle

public function configTitle()
Default handler for the "title" property
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

deselect

public function deselect(String/Date/Date[] date)
Deselects a date or a collection of dates on the current calendar. This method, by default, does not call the render method explicitly. Once deselection has completed, render must be called for the changes to be reflected visually.
Parameters:
  • date : String/Date/Date[]
    The date string of dates to deselect in the current calendar. Valid formats are individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). This method can also take a JavaScript Date object or an array of Date objects.
Returns:
  • Date[]
    Array of JavaScript Date objects representing all individual dates that are currently selected.
This method is defined by DateMath.

deselectAll

public function deselectAll()
Deselects all dates on the current calendar.
Parameters:
  • None.
Returns:
  • Date[]
    Array of JavaScript Date objects representing all individual dates that are currently selected. Assuming that this function executes properly, the return value should be an empty array. However, the empty array is returned for the sake of being able to check the selection status of the calendar.
This method is defined by DateMath.

deselectCell

public function deselectCell(Number cellIndex)
Deselects a date on the current calendar by referencing the index of the cell that should be deselected. This method is used to easily deselect a single cell (usually with a mouse click) without having to do a full render. The selected style is removed from the cell directly.
Parameters:
  • cellIndex : Number
    The index of the cell to deselect in the current calendar.
Returns:
  • Date[]
    Array of JavaScript Date objects representing all individual dates that are currently selected.
This method is defined by DateMath.

doCellMouseOut

public function doCellMouseOut(DOMEvent e, Calendar cal)
The event that is executed when the user moves the mouse out of a cell
Parameters:
  • e : DOMEvent
    The event
  • cal : Calendar
    A reference to the calendar passed by the Event utility
Returns:
  • void
This method is defined by DateMath.

doCellMouseOver

public function doCellMouseOver(DOMEvent e, Calendar cal)
The event that is executed when the user hovers over a cell
Parameters:
  • e : DOMEvent
    The event
  • cal : Calendar
    A reference to the calendar passed by the Event utility
Returns:
  • void
This method is defined by DateMath.

doSelectCell

public function doSelectCell(DOMEvent e, Calendar cal)
The default event function that is attached to a date link within a calendar cell when the calendar is rendered.
Parameters:
  • e : DOMEvent
    The event
  • cal : Calendar
    A reference to the calendar passed by the Event utility
Returns:
  • void
This method is defined by DateMath.

findMonthEnd

public function findMonthEnd(Date 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
This method is defined by DateMath.

findMonthStart

public function findMonthStart(Date 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
This method is defined by DateMath.

getDateByCellId

public function getDateByCellId(String id)
Retrieves the Date object for the specified Calendar cell
Parameters:
  • id : String
    The id of the cell
Returns:
  • Date
    The Date object for the specified Calendar cell
This method is defined by DateMath.

getDateFieldsByCellId

public function getDateFieldsByCellId(String id)
Retrieves the Date object for the specified Calendar cell
Parameters:
  • id : String
    The id of the cell
Returns:
  • Array
    The array of Date fields for the specified Calendar cell
This method is defined by DateMath.

getDayOffset

public function getDayOffset(Date date, Number 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
This method is defined by DateMath.

getJan1

public function getJan1(Number 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.
This method is defined by DateMath.

getSelectedDates

public function getSelectedDates()
Gets the list of currently selected dates from the calendar.
Parameters:
  • None.
Returns:
  • Date[]
    An array of currently selected JavaScript Date objects.
This method is defined by DateMath.

getWeekNumber

public function getWeekNumber(Date date, Number calendarYear, Number weekStartsOn)
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".
  • weekStartsOn : Number
    OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
Returns:
  • Number
    The week number of the given date.
This method is defined by DateMath.

hide

public function hide()
Hides the Calendar's outer container from view.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

init

public function init(String id, String containerId, Object config)
Initializes the Calendar widget.
Parameters:
  • id : String
    The id of the table element that will represent the calendar widget
  • containerId : String
    The id of the container div element that will wrap the calendar table
  • config : Object
    The configuration object containing the Calendar's arguments
Returns:
  • void
This method is defined by DateMath.

initEvents

public function initEvents()
Initializes Calendar's built-in CustomEvents
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

initStyles

public function initStyles()
Defines the style constants for the Calendar
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

isDateOOM

public function isDateOOM(Date date)
Determines whether a given date is OOM (out of month).
Parameters:
  • date : Date
    The JavaScript Date object for which to check the OOM status
Returns:
  • Boolean
    true if the date is OOM
This method is defined by DateMath.

isMonthOverlapWeek

public function isMonthOverlapWeek(Date 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.
This method is defined by DateMath.

isYearOverlapWeek

public function isYearOverlapWeek(Date 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.
This method is defined by DateMath.

nextMonth

public function nextMonth()
Navigates to the next month page in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

nextYear

public function nextYear()
Navigates to the next year in the currently selected month in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

onBeforeDeselect

public function onBeforeDeselect()
Deprecated. Event executed before a date is deselected in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

onBeforeSelect

public function onBeforeSelect()
Deprecated. Event executed before a date is selected in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

onChangePage

public function onChangePage()
Deprecated. Event executed when the user navigates to a different calendar page.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

onDeselect

public function onDeselect(Array selected)
Deprecated. Event executed when a date is deselected in the calendar widget.
Parameters:
  • selected : Array
    An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
Returns:
  • void
This method is defined by DateMath.

onRender

public function onRender()
Deprecated. Event executed when the calendar widget is rendered.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

onSelect

public function onSelect(Array selected)
Deprecated. Event executed when a date is selected in the calendar widget.
Parameters:
  • selected : Array
    An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ]
Returns:
  • void
This method is defined by DateMath.

previousMonth

public function previousMonth()
Navigates to the previous month page in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

previousYear

public function previousYear()
Navigates to the previous year in the currently selected month in the calendar widget.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

render

public function render()
Deprecated. Event executed when the calendar widget is completely cleared to the current month with no selections.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

renderBody

public function renderBody(Date workingDate, Array html)
Renders the calendar body.
Parameters:
  • workingDate : Date
    The current working Date being used for the render process
  • html : Array
    The current working HTML array
Returns:
  • Array
    The current working HTML array
This method is defined by DateMath.

renderBodyCellRestricted

public function renderBodyCellRestricted(Date workingDate, HTMLTableCellElement cell)
Renders the current calendar cell as a non-selectable "black-out" date using the default restricted style.
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • String
    YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering should not be terminated
This method is defined by DateMath.

renderCellDefault

public function renderCellDefault(Date workingDate, HTMLTableCellElement cell)
Renders a single standard calendar cell in the calendar widget table. All logic for determining how a standard default cell will be rendered is encapsulated in this method, and must be accounted for when extending the widget class.
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderCellNotThisMonth

public function renderCellNotThisMonth(Date workingDate, HTMLTableCellElement cell)
Applies the default style used for rendering dates that are not a part of the current month (preceding or trailing the cells for the current month)
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • String
    YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering should not be terminated
This method is defined by DateMath.

renderCellStyleHighlight1

public function renderCellStyleHighlight1(Date workingDate, HTMLTableCellElement cell)
Renders a single standard calendar cell using the CSS hightlight1 style
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderCellStyleHighlight2

public function renderCellStyleHighlight2(Date workingDate, HTMLTableCellElement cell)
Renders a single standard calendar cell using the CSS hightlight2 style
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderCellStyleHighlight3

public function renderCellStyleHighlight3(Date workingDate, HTMLTableCellElement cell)
Renders a single standard calendar cell using the CSS hightlight3 style
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderCellStyleHighlight4

public function renderCellStyleHighlight4(Date workingDate, HTMLTableCellElement cell)
Renders a single standard calendar cell using the CSS hightlight4 style
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderCellStyleSelected

public function renderCellStyleSelected(Date workingDate, HTMLTableCellElement cell)
Applies the default style used for rendering selected dates to the current calendar cell
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • String
    YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering should not be terminated
This method is defined by DateMath.

renderCellStyleToday

public function renderCellStyleToday(Date workingDate, HTMLTableCellElement cell)
Applies the default style used for rendering today's date to the current calendar cell
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

renderFooter

public function renderFooter(Array html)
Renders the calendar footer. In the default implementation, there is no footer.
Parameters:
  • html : Array
    The current working HTML array
Returns:
  • Array
    The current working HTML array
This method is defined by DateMath.

renderHeader

public function renderHeader(Array html)
Renders the calendar header.
Parameters:
  • html : Array
    The current working HTML array
Returns:
  • Array
    The current working HTML array
This method is defined by DateMath.

renderOutOfBoundsDate

public function renderOutOfBoundsDate(Date workingDate, HTMLTableCellElement cell)
Renders a cell that falls before the minimum date or after the maximum date. widget class.
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • String
    YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering should not be terminated
This method is defined by DateMath.

renderRowFooter

public function renderRowFooter(Number weekNum, Array cell)
Renders the row footer for a week.
Parameters:
  • weekNum : Number
    The week number of the current row
  • cell : Array
    The current working HTML array
Returns:
  • void
This method is defined by DateMath.

renderRowHeader

public function renderRowHeader(Number weekNum, Array cell)
Renders the row header for a week.
Parameters:
  • weekNum : Number
    The week number of the current row
  • cell : Array
    The current working HTML array
Returns:
  • void
This method is defined by DateMath.

reset

public function reset()
Resets the calendar widget to the originally selected month and year, and sets the calendar to the initial selection(s).
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

resetRenderers

public function resetRenderers()
Resets the render stack of the current calendar to its original pre-render value.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

select

public function select(String/Date/Date[] date)
Selects a date or a collection of dates on the current calendar. This method, by default, does not call the render method explicitly. Once selection has completed, render must be called for the changes to be reflected visually.
Parameters:
  • date : String/Date/Date[]
    The date string of dates to select in the current calendar. Valid formats are individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). This method can also take a JavaScript Date object or an array of Date objects.
Returns:
  • Date[]
    Array of JavaScript Date objects representing all individual dates that are currently selected.
This method is defined by DateMath.

selectCell

public function selectCell(Number cellIndex)
Selects a date on the current calendar by referencing the index of the cell that should be selected. This method is used to easily select a single cell (usually with a mouse click) without having to do a full render. The selected style is applied to the cell directly.
Parameters:
  • cellIndex : Number
    The index of the cell to select in the current calendar.
Returns:
  • Date[]
    Array of JavaScript Date objects representing all individual dates that are currently selected.
This method is defined by DateMath.

setMonth

public function setMonth(Number month)
Sets the calendar's month explicitly
Parameters:
  • month : Number
    The numeric month, from 0 (January) to 11 (December)
Returns:
  • void
This method is defined by DateMath.

setYear

public function setYear(Number year)
Sets the calendar's year explicitly.
Parameters:
  • year : Number
    The numeric 4-digit year
Returns:
  • void
This method is defined by DateMath.

show

public function show()
Shows the Calendar's outer container.
Parameters:
  • None.
Returns:
  • void
This method is defined by DateMath.

styleCellDefault

public function styleCellDefault(Date workingDate, HTMLTableCellElement cell)
Styles a selectable cell.
Parameters:
  • workingDate : Date
    The current working Date object being used to generate the calendar
  • cell : HTMLTableCellElement
    The current working cell in the calendar
Returns:
  • void
This method is defined by DateMath.

subtract

public function subtract(Date date, Number field, Number 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
This method is defined by DateMath.

subtractMonths

public function subtractMonths(Number count)
Subtracts the designated number of months from the current calendar month, and sets the current calendar page date to the new month.
Parameters:
  • count : Number
    The number of months to subtract from the current calendar
Returns:
  • void
This method is defined by DateMath.

subtractYears

public function subtractYears(Number count)
Subtcats the designated number of years from the current calendar, and sets the current calendar page date to the new month.
Parameters:
  • count : Number
    The number of years to subtract from the current calendar
Returns:
  • void
This method is defined by DateMath.

toString

public function toString()
Returns a string representation of the object.
Parameters:
  • None.
Returns:
  • String
    A string representation of the Calendar object.
This method is defined by DateMath.

validate

public function validate()
Validates the calendar widget. This method has no default implementation and must be extended by subclassing the widget.
Parameters:
  • None.
Returns:
  • Should
    return true if the widget validates, and false if it doesn't.
This method is defined by DateMath.

Event Details

beforeDeselectEvent

public event beforeDeselectEvent
Fired before a selection is made
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

beforeRenderEvent

public event beforeRenderEvent
Fired before the Calendar is rendered
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

beforeSelectEvent

public event beforeSelectEvent
Fired before a selection is made
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

changePageEvent

public event changePageEvent
Fired when the Calendar page is changed
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

clearEvent

public event clearEvent
Fired when the Calendar is cleared
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

deselectEvent

public event deselectEvent
Fired when a selection is made
Subscribers will be called with the following parameters:
  • Array : Array
    of Date field arrays in the format [YYYY, MM, DD].
This event is defined by DateMath.

renderEvent

public event renderEvent
Fired when the Calendar is rendered
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

resetEvent

public event resetEvent
Fired when the Calendar is reset
Subscribers will be called with the following parameters:
  • None.
This event is defined by DateMath.

selectEvent

public event selectEvent
Fired when a selection is made
Subscribers will be called with the following parameters:
  • Array : Array
    of Date field arrays in the format [YYYY, MM, DD].
This event is defined by DateMath.

Copyright © 2006 Jack Slocum. All rights reserved.