X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..refs/heads/master:/docs/source/Date.html diff --git a/docs/source/Date.html b/docs/source/Date.html index d07482d2..57fe7890 100644 --- a/docs/source/Date.html +++ b/docs/source/Date.html @@ -3,8 +3,8 @@
/** - * @class Ext.picker.Date - * @extends Ext.Component - * <p>A date picker. This class is used by the {@link Ext.form.field.Date} field to allow browsing and - * selection of valid dates in a popup next to the field, but may also be used with other components.</p> - * <p>Typically you will need to implement a handler function to be notified when the user chooses a color from the - * picker; you can register the handler using the {@link #select} event, or by implementing the {@link #handler} - * method.</p> - * <p>By default the user will be allowed to pick any date; this can be changed by using the {@link #minDate}, - * {@link #maxDate}, {@link #disabledDays}, {@link #disabledDatesRE}, and/or {@link #disabledDates} configs.</p> - * <p>All the string values documented below may be overridden by including an Ext locale file in your page.</p> - * <p>Example usage:</p> - * <pre><code>new Ext.panel.Panel({ - title: 'Choose a future date:', - width: 200, - bodyPadding: 10, - renderTo: Ext.getBody(), - items: [{ - xtype: 'datepicker', - minDate: new Date(), - handler: function(picker, date) { - // do something with the selected date - } - }] -});</code></pre> - * {@img Ext.picker.Date/Ext.picker.Date.png Ext.picker.Date component} - * - */ -Ext.define('Ext.picker.Date', { - extend: 'Ext.Component', - requires: [ - 'Ext.XTemplate', - 'Ext.button.Button', - 'Ext.button.Split', - 'Ext.util.ClickRepeater', - 'Ext.util.KeyNav', - 'Ext.EventObject', - 'Ext.fx.Manager', - 'Ext.picker.Month' - ], - alias: 'widget.datepicker', - alternateClassName: 'Ext.DatePicker', - - renderTpl: [ - '<div class="{cls}" id="{id}" role="grid" title="{ariaTitle} {value:this.longDay}">', - '<div role="presentation" class="{baseCls}-header">', - '<div class="{baseCls}-prev"><a href="#" role="button" title="{prevText}"></a></div>', - '<div class="{baseCls}-month"></div>', - '<div class="{baseCls}-next"><a href="#" role="button" title="{nextText}"></a></div>', - '</div>', - '<table class="{baseCls}-inner" cellspacing="0" role="presentation">', - '<thead role="presentation"><tr role="presentation">', - '<tpl for="dayNames">', - '<th role="columnheader" title="{.}"><span>{.:this.firstInitial}</span></th>', - '</tpl>', - '</tr></thead>', - '<tbody role="presentation"><tr role="presentation">', - '<tpl for="days">', - '{#:this.isEndOfWeek}', - '<td role="gridcell" id="{[Ext.id()]}">', - '<a role="presentation" href="#" hidefocus="on" class="{parent.baseCls}-date" tabIndex="1">', - '<em role="presentation"><span role="presentation"></span></em>', - '</a>', - '</td>', - '</tpl>', - '</tr></tbody>', - '</table>', - '<tpl if="showToday">', - '<div role="presentation" class="{baseCls}-footer"></div>', - '</tpl>', - '</div>', - { - firstInitial: function(value) { - return value.substr(0,1); - }, - isEndOfWeek: function(value) { - // convert from 1 based index to 0 based - // by decrementing value once. - value--; - var end = value % 7 === 0 && value !== 0; - return end ? '</tr><tr role="row">' : ''; - }, - longDay: function(value){ - return Ext.Date.format(value, this.longDayFormat); - } - } - ], - - ariaTitle: 'Date Picker', - /** - * @cfg {String} todayText - * The text to display on the button that selects the current date (defaults to <code>'Today'</code>) - */ - todayText : 'Today', - /** - * @cfg {Function} handler - * Optional. A function that will handle the select event of this picker. - * The handler is passed the following parameters:<div class="mdetail-params"><ul> - * <li><code>picker</code> : Ext.picker.Date <div class="sub-desc">This Date picker.</div></li> - * <li><code>date</code> : Date <div class="sub-desc">The selected date.</div></li> - * </ul></div> - */ - /** - * @cfg {Object} scope - * The scope (<code><b>this</b></code> reference) in which the <code>{@link #handler}</code> - * function will be called. Defaults to this DatePicker instance. - */ - /** - * @cfg {String} todayTip - * A string used to format the message for displaying in a tooltip over the button that - * selects the current date. Defaults to <code>'{0} (Spacebar)'</code> where - * the <code>{0}</code> token is replaced by today's date. - */ - todayTip : '{0} (Spacebar)', - /** - * @cfg {String} minText - * The error text to display if the minDate validation fails (defaults to <code>'This date is before the minimum date'</code>) - */ - minText : 'This date is before the minimum date', - /** - * @cfg {String} maxText - * The error text to display if the maxDate validation fails (defaults to <code>'This date is after the maximum date'</code>) - */ - maxText : 'This date is after the maximum date', - /** - * @cfg {String} format - * The default date format string which can be overriden for localization support. The format must be - * valid according to {@link Ext.Date#parse} (defaults to {@link Ext.Date#defaultFormat}). - */ - /** - * @cfg {String} disabledDaysText - * The tooltip to display when the date falls on a disabled day (defaults to <code>'Disabled'</code>) - */ - disabledDaysText : 'Disabled', - /** - * @cfg {String} disabledDatesText - * The tooltip text to display when the date falls on a disabled date (defaults to <code>'Disabled'</code>) - */ - disabledDatesText : 'Disabled', - /** - * @cfg {Array} monthNames - * An array of textual month names which can be overriden for localization support (defaults to Ext.Date.monthNames) - */ - /** - * @cfg {Array} dayNames - * An array of textual day names which can be overriden for localization support (defaults to Ext.Date.dayNames) - */ - /** - * @cfg {String} nextText - * The next month navigation button tooltip (defaults to <code>'Next Month (Control+Right)'</code>) - */ - nextText : 'Next Month (Control+Right)', - /** - * @cfg {String} prevText - * The previous month navigation button tooltip (defaults to <code>'Previous Month (Control+Left)'</code>) - */ - prevText : 'Previous Month (Control+Left)', - /** - * @cfg {String} monthYearText - * The header month selector tooltip (defaults to <code>'Choose a month (Control+Up/Down to move years)'</code>) - */ - monthYearText : 'Choose a month (Control+Up/Down to move years)', - /** - * @cfg {Number} startDay - * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday) - */ - startDay : 0, - /** - * @cfg {Boolean} showToday - * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar - * that selects the current date (defaults to <code>true</code>). - */ - showToday : true, - /** - * @cfg {Date} minDate - * Minimum allowable date (JavaScript date object, defaults to null) - */ - /** - * @cfg {Date} maxDate - * Maximum allowable date (JavaScript date object, defaults to null) - */ - /** - * @cfg {Array} disabledDays - * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null). - */ - /** - * @cfg {RegExp} disabledDatesRE - * JavaScript regular expression used to disable a pattern of dates (defaults to null). The {@link #disabledDates} - * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the - * disabledDates value. - */ - /** - * @cfg {Array} disabledDates - * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular - * expression so they are very powerful. Some examples: - * <ul> - * <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li> - * <li>['03/08', '09/16'] would disable those days for every year</li> - * <li>['^03/08'] would only match the beginning (useful if you are using short years)</li> - * <li>['03/../2006'] would disable every day in March 2006</li> - * <li>['^03'] would disable every day in every March</li> - * </ul> - * Note that the format of the dates included in the array should exactly match the {@link #format} config. - * In order to support regular expressions, if you are using a date format that has '.' in it, you will have to - * escape the dot when restricting dates. For example: ['03\\.08\\.03']. - */ - - /** - * @cfg {Boolean} disableAnim True to disable animations when showing the month picker. Defaults to <tt>false</tt>. - */ - disableAnim: true, - - /** - * @cfg {String} baseCls - * The base CSS class to apply to this components element (defaults to <tt>'x-datepicker'</tt>). - */ - baseCls: Ext.baseCSSPrefix + 'datepicker', - - /** - * @cfg {String} selectedCls - * The class to apply to the selected cell. Defaults to <tt>'x-datepicker-selected'</tt> - */ - - /** - * @cfg {String} disabledCellCls - * The class to apply to disabled cells. Defaults to <tt>'x-datepicker-disabled'</tt> - */ - - /** - * @cfg {String} longDayFormat - * The format for displaying a date in a longer format. Defaults to <tt>'F d, Y'</tt> - */ - longDayFormat: 'F d, Y', - - * @cfg {Object} keyNavConfig Specifies optional custom key event handlers for the {@link Ext.util.KeyNav} - * attached to this date picker. Must conform to the config format recognized by the {@link Ext.util.KeyNav} - * constructor. Handlers specified in this object will replace default handlers of the same name. - */ - - /** - * @cfg {Boolean} focusOnShow - * True to automatically focus the picker on show. Defaults to <tt>false</tt>. - */ - focusOnShow: false, - - // private - // Set by other components to stop the picker focus being updated when the value changes. - focusOnSelect: true, - - width: 178, - - // default value used to initialise each date in the DatePicker - // (note: 12 noon was chosen because it steers well clear of all DST timezone changes) - initHour: 12, // 24-hour format - - numDays: 42, - - // private, inherit docs - initComponent : function() { - var me = this, - clearTime = Ext.Date.clearTime; - - me.selectedCls = me.baseCls + '-selected'; - me.disabledCellCls = me.baseCls + '-disabled'; - me.prevCls = me.baseCls + '-prevday'; - me.activeCls = me.baseCls + '-active'; - me.nextCls = me.baseCls + '-prevday'; - me.todayCls = me.baseCls + '-today'; - me.dayNames = me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay)); - this.callParent(); - - me.value = me.value ? - clearTime(me.value, true) : clearTime(new Date()); - - me.addEvents( - /** - * @event select - * Fires when a date is selected - * @param {DatePicker} this DatePicker - * @param {Date} date The selected date - */ - 'select' - ); - - me.initDisabledDays(); - }, - - // private, inherit docs - onRender : function(container, position){ - /* - * days array for looping through 6 full weeks (6 weeks * 7 days) - * Note that we explicitly force the size here so the template creates - * all the appropriate cells. - */ - - var me = this, - days = new Array(me.numDays), - today = Ext.Date.format(new Date(), me.format); - - Ext.applyIf(me, { - renderData: {}, - renderSelectors: {} - }); - - Ext.apply(me.renderData, { - dayNames: me.dayNames, - ariaTitle: me.ariaTitle, - value: me.value, - showToday: me.showToday, - prevText: me.prevText, - nextText: me.nextText, - days: days - }); - me.getTpl('renderTpl').longDayFormat = me.longDayFormat; - - Ext.apply(me.renderSelectors, { - eventEl: 'table.' + me.baseCls + '-inner', - prevEl: '.' + me.baseCls + '-prev a', - nextEl: '.' + me.baseCls + '-next a', - middleBtnEl: '.' + me.baseCls + '-month', - footerEl: '.' + me.baseCls + '-footer' - }); - - this.callParent(arguments); - me.el.unselectable(); - - me.cells = me.eventEl.select('tbody td'); - me.textNodes = me.eventEl.query('tbody td span'); - - me.monthBtn = Ext.create('Ext.button.Split', { - text: '', - tooltip: me.monthYearText, - renderTo: me.middleBtnEl - }); - //~ me.middleBtnEl.down('button').addCls(Ext.baseCSSPrefix + 'btn-arrow'); - - - me.todayBtn = Ext.create('Ext.button.Button', { - renderTo: me.footerEl, - text: Ext.String.format(me.todayText, today), - tooltip: Ext.String.format(me.todayTip, today), - handler: me.selectToday, - scope: me - }); - }, - - // private, inherit docs - initEvents: function(){ - var me = this, - eDate = Ext.Date, - day = eDate.DAY; - - this.callParent(); - - me.prevRepeater = Ext.create('Ext.util.ClickRepeater', me.prevEl, { - handler: me.showPrevMonth, - scope: me, - preventDefault: true, - stopDefault: true - }); - - me.nextRepeater = Ext.create('Ext.util.ClickRepeater', me.nextEl, { - handler: me.showNextMonth, - scope: me, - preventDefault:true, - stopDefault:true - }); - - me.keyNav = Ext.create('Ext.util.KeyNav', me.eventEl, Ext.apply({ - scope: me, - 'left' : function(e){ - if(e.ctrlKey){ - me.showPrevMonth(); - }else{ - me.update(eDate.add(me.activeDate, day, -1)); - } - }, - - 'right' : function(e){ - if(e.ctrlKey){ - me.showNextMonth(); - }else{ - me.update(eDate.add(me.activeDate, day, 1)); - } - }, - - 'up' : function(e){ - if(e.ctrlKey){ - me.showNextYear(); - }else{ - me.update(eDate.add(me.activeDate, day, -7)); - } - }, - - 'down' : function(e){ - if(e.ctrlKey){ - me.showPrevYear(); - }else{ - me.update(eDate.add(me.activeDate, day, 7)); - } - }, - 'pageUp' : me.showNextMonth, - 'pageDown' : me.showPrevMonth, - 'enter' : function(e){ - e.stopPropagation(); - return true; - } - }, me.keyNavConfig)); - - if(me.showToday){ - me.todayKeyListener = me.eventEl.addKeyListener(Ext.EventObject.SPACE, me.selectToday, me); - } - me.mon(me.eventEl, 'mousewheel', me.handleMouseWheel, me); - me.mon(me.eventEl, 'click', me.handleDateClick, me, {delegate: 'a.' + me.baseCls + '-date'}); - me.mon(me.monthBtn, 'click', me.showMonthPicker, me); - me.mon(me.monthBtn, 'arrowclick', me.showMonthPicker, me); - me.update(me.value); - }, - - /** - * Setup the disabled dates regex based on config options - * @private - */ - initDisabledDays : function(){ - var me = this, - dd = me.disabledDates, - re = '(?:', - len; - - if(!me.disabledDatesRE && dd){ - len = dd.length - 1; - - Ext.each(dd, function(d, i){ - re += Ext.isDate(d) ? '^' + Ext.String.escapeRegex(Ext.Date.dateFormat(d, me.format)) + '$' : dd[i]; - if(i != len){ - re += '|'; - } - }, me); - me.disabledDatesRE = new RegExp(re + ')'); - } - }, - - /** - * Replaces any existing disabled dates with new values and refreshes the DatePicker. - * @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config - * for details on supported values), or a JavaScript regular expression used to disable a pattern of dates. - * @return {Ext.picker.Date} this - */ - setDisabledDates : function(dd){ - var me = this; - - if(Ext.isArray(dd)){ - me.disabledDates = dd; - me.disabledDatesRE = null; - }else{ - me.disabledDatesRE = dd; - } - me.initDisabledDays(); - me.update(me.value, true); - return me; - }, - - /** - * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker. - * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config - * for details on supported values. - * @return {Ext.picker.Date} this - */ - setDisabledDays : function(dd){ - this.disabledDays = dd; - return this.update(this.value, true); - }, - - /** - * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker. - * @param {Date} value The minimum date that can be selected - * @return {Ext.picker.Date} this - */ - setMinDate : function(dt){ - this.minDate = dt; - return this.update(this.value, true); - }, - - /** - * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker. - * @param {Date} value The maximum date that can be selected - * @return {Ext.picker.Date} this - */ - setMaxDate : function(dt){ - this.maxDate = dt; - return this.update(this.value, true); - }, - - /** - * Sets the value of the date field - * @param {Date} value The date to set - * @return {Ext.picker.Date} this - */ - setValue : function(value){ - this.value = Ext.Date.clearTime(value, true); - return this.update(this.value); - }, - - /** - * Gets the current selected value of the date field - * @return {Date} The selected date - */ - getValue : function(){ - return this.value; - }, - - // private - focus : function(){ - this.update(this.activeDate); - }, - - // private, inherit docs - onEnable: function(){ - this.callParent(); - this.setDisabledStatus(false); - this.update(this.activeDate); - - }, - - // private, inherit docs - onDisable : function(){ - this.callParent(); - this.setDisabledStatus(true); - }, - - /** - * Set the disabled state of various internal components - * @private - * @param {Boolean} disabled - */ - setDisabledStatus : function(disabled){ - var me = this; - - me.keyNav.setDisabled(disabled); - me.prevRepeater.setDisabled(disabled); - me.nextRepeater.setDisabled(disabled); - if (me.showToday) { - me.todayKeyListener.setDisabled(disabled); - me.todayBtn.setDisabled(disabled); - } - }, - - /** - * Get the current active date. - * @private - * @return {Date} The active date - */ - getActive: function(){ - return this.activeDate || me.value; - }, - - /** - * Run any animation required to hide/show the month picker. - * @private - * @param {Boolean} isHide True if it's a hide operation - */ - runAnimation: function(isHide){ - var options = { - target: this.monthPicker, - duration: 200 - }; - - Ext.fx.Manager.run(); - if (isHide) { - //TODO: slideout - } else { - //TODO: slidein - } - Ext.create('Ext.fx.Anim', options); - }, - - /** - * Hides the month picker, if it's visible. - * @return {Ext.picker.Date} this - */ - hideMonthPicker : function(){ - var me = this, - picker = me.monthPicker; - - if (picker) { - if (me.disableAnim) { - picker.hide(); - } else { - this.runAnimation(true); - } - } - return me; - }, - - /** - * Show the month picker - * @return {Ext.picker.Date} this - */ - showMonthPicker : function(){ - - var me = this, - picker, - size, - top, - left; - - - if (me.rendered && !me.disabled) { - size = me.getSize(); - picker = me.createMonthPicker(); - picker.show(); - picker.setSize(size); - picker.setValue(me.getActive()); - - if (me.disableAnim) { - picker.setPosition(-1, -1); - } else { - me.runAnimation(false); - } - } - return me; - }, - - /** - * Create the month picker instance - * @private - * @return {Ext.picker.Month} picker - */ - createMonthPicker: function(){ - var me = this, - picker = me.monthPicker; - - if (!picker) { - me.monthPicker = picker = Ext.create('Ext.picker.Month', { - renderTo: me.el, - floating: true, - shadow: false, - small: me.showToday === false, - listeners: { - scope: me, - cancelclick: me.onCancelClick, - okclick: me.onOkClick, - yeardblclick: me.onOkClick, - monthdblclick: me.onOkClick - } - }); - - me.on('beforehide', me.hideMonthPicker, me); - } - return picker; - }, - - /** - * Respond to an ok click on the month picker - * @private - */ - onOkClick: function(picker, value){ - var me = this, - month = value[0], - year = value[1], - date = new Date(year, month, me.getActive().getDate()); - - if (date.getMonth() !== month) { - // 'fix' the JS rolling date conversion if needed - date = new Date(year, month, 1).getLastDateOfMonth(); - } - me.update(date); - me.hideMonthPicker(); - }, - - /** - * Respond to a cancel click on the month picker - * @private - */ - onCancelClick: function(){ - this.hideMonthPicker(); - }, - - /** - * Show the previous month. - * @return {Ext.picker.Date} this - */ - showPrevMonth : function(e){ - return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, -1)); - }, - - /** - * Show the next month. - * @return {Ext.picker.Date} this - */ - showNextMonth : function(e){ - return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, 1)); - }, - - /** - * Show the previous year. - * @return {Ext.picker.Date} this - */ - showPrevYear : function(){ - this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, -1)); - }, - - /** - * Show the next year. - * @return {Ext.picker.Date} this - */ - showNextYear : function(){ - this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, 1)); - }, - - /** - * Respond to the mouse wheel event - * @private - * @param {Ext.EventObject} e - */ - handleMouseWheel : function(e){ - e.stopEvent(); - if(!this.disabled){ - var delta = e.getWheelDelta(); - if(delta > 0){ - this.showPrevMonth(); - } else if(delta < 0){ - this.showNextMonth(); - } - } - }, - - /** - * Respond to a date being clicked in the picker - * @private - * @param {Ext.EventObject} e - * @param {HTMLElement} t - */ - handleDateClick : function(e, t){ - var me = this, - handler = me.handler; - - e.stopEvent(); - if(!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)){ - me.cancelFocus = me.focusOnSelect === false; - me.setValue(new Date(t.dateValue)); - delete me.cancelFocus; - me.fireEvent('select', me, me.value); - if (handler) { - handler.call(me.scope || me, me, me.value); - } - // event handling is turned off on hide - // when we are using the picker in a field - // therefore onSelect comes AFTER the select - // event. - me.onSelect(); - } - }, - - /** - * Perform any post-select actions - * @private - */ - onSelect: function() { - if (this.hideOnSelect) { - this.hide(); - } - }, - - /** - * Sets the current value to today. - * @return {Ext.picker.Date} this - */ - selectToday : function(){ - var me = this, - btn = me.todayBtn, - handler = me.handler; - - if(btn && !btn.disabled){ - me.setValue(Ext.Date.clearTime(new Date())); - me.fireEvent('select', me, me.value); - if (handler) { - handler.call(me.scope || me, me, me.value); - } - me.onSelect(); - } - return me; - }, - - /** - * Update the selected cell - * @private - * @param {Date} date The new date - * @param {Date} active The active date - */ - selectedUpdate: function(date, active){ - var me = this, - t = date.getTime(), - cells = me.cells, - cls = me.selectedCls; - - cells.removeCls(cls); - cells.each(function(c){ - if (c.dom.firstChild.dateValue == t) { - me.el.dom.setAttribute('aria-activedescendent', c.dom.id); - c.addCls(cls); - if(me.isVisible() && !me.cancelFocus){ - Ext.fly(c.dom.firstChild).focus(50); - } - return false; - } - }, this); - }, - - /** - * Update the contents of the picker for a new month - * @private - * @param {Date} date The new date - * @param {Date} active The active date - */ - fullUpdate: function(date, active){ - var me = this, - cells = me.cells.elements, - textNodes = me.textNodes, - disabledCls = me.disabledCellCls, - eDate = Ext.Date, - i = 0, - extraDays = 0, - visible = me.isVisible(), - sel = +eDate.clearTime(date, true), - today = +eDate.clearTime(new Date()), - min = me.minDate ? eDate.clearTime(me.minDate, true) : Number.NEGATIVE_INFINITY, - max = me.maxDate ? eDate.clearTime(me.maxDate, true) : Number.POSITIVE_INFINITY, - ddMatch = me.disabledDatesRE, - ddText = me.disabledDatesText, - ddays = me.disabledDays ? me.disabledDays.join('') : false, - ddaysText = me.disabledDaysText, - format = me.format, - days = eDate.getDaysInMonth(date), - firstOfMonth = eDate.getFirstDateOfMonth(date), - startingPos = firstOfMonth.getDay() - me.startDay, - previousMonth = eDate.add(date, eDate.MONTH, -1), - longDayFormat = me.longDayFormat, - prevStart, - current, - disableToday, - tempDate, - setCellClass, - html, - cls, - formatValue, - value; - - if (startingPos < 0) { - startingPos += 7; - } - - days += startingPos; - prevStart = eDate.getDaysInMonth(previousMonth) - startingPos; - current = new Date(previousMonth.getFullYear(), previousMonth.getMonth(), prevStart, me.initHour); - - if (me.showToday) { - tempDate = eDate.clearTime(new Date()); - disableToday = (tempDate < min || tempDate > max || - (ddMatch && format && ddMatch.test(eDate.dateFormat(tempDate, format))) || - (ddays && ddays.indexOf(tempDate.getDay()) != -1)); - - if (!me.disabled) { - me.todayBtn.setDisabled(disableToday); - me.todayKeyListener.setDisabled(disableToday); - } - } - - setCellClass = function(cell){ - value = +eDate.clearTime(current, true); - cell.title = eDate.format(current, longDayFormat); - // store dateValue number as an expando - cell.firstChild.dateValue = value; - if(value == today){ - cell.className += ' ' + me.todayCls; - cell.title = me.todayText; - } - if(value == sel){ - cell.className += ' ' + me.selectedCls; - me.el.dom.setAttribute('aria-activedescendant', cell.id); - if (visible && me.floating) { - Ext.fly(cell.firstChild).focus(50); - } - } - // disabling - if(value < min) { - cell.className = disabledCls; - cell.title = me.minText; - return; - } - if(value > max) { - cell.className = disabledCls; - cell.title = me.maxText; - return; - } - if(ddays){ - if(ddays.indexOf(current.getDay()) != -1){ - cell.title = ddaysText; - cell.className = disabledCls; - } - } - if(ddMatch && format){ - formatValue = eDate.dateFormat(current, format); - if(ddMatch.test(formatValue)){ - cell.title = ddText.replace('%0', formatValue); - cell.className = disabledCls; - } - } - }; - - for(; i < me.numDays; ++i) { - if (i < startingPos) { - html = (++prevStart); - cls = me.prevCls; - } else if (i >= days) { - html = (++extraDays); - cls = me.nextCls; - } else { - html = i - startingPos + 1; - cls = me.activeCls; - } - textNodes[i].innerHTML = html; - cells[i].className = cls; - current.setDate(current.getDate() + 1); - setCellClass(cells[i]); - } - - me.monthBtn.setText(me.monthNames[date.getMonth()] + ' ' + date.getFullYear()); - }, - - /** - * Update the contents of the picker - * @private - * @param {Date} date The new date - * @param {Boolean} forceRefresh True to force a full refresh - */ - update : function(date, forceRefresh){ - var me = this, - active = me.activeDate; - - if (me.rendered) { - me.activeDate = date; - if(!forceRefresh && active && me.el && active.getMonth() == date.getMonth() && active.getFullYear() == date.getFullYear()){ - me.selectedUpdate(date, active); - } else { - me.fullUpdate(date, active); - } - } - return me; - }, - - // private, inherit docs - beforeDestroy : function() { - var me = this; - - if (me.rendered) { - Ext.destroy( - me.todayKeyListener, - me.keyNav, - me.monthPicker, - me.monthBtn, - me.nextRepeater, - me.prevRepeater, - me.todayBtn - ); - delete me.textNodes; - delete me.cells.elements; - } - }, - - // private, inherit docs - onShow: function() { - this.callParent(arguments); - if (this.focusOnShow) { - this.focus(); - } - } -}, +/** + * @class Date + * + * Creates `Date` instances which let you work with dates and times. + * + * If you supply no arguments, the constructor creates a `Date` object for today's + * date and time according to local time. If you supply some arguments but not + * others, the missing arguments are set to 0. If you supply any arguments, you + * must supply at least the year, month, and day. You can omit the hours, minutes, + * seconds, and milliseconds. + * + * The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day + * holds 86,400,000 milliseconds. The `Date` object range is -100,000,000 days to + * 100,000,000 days relative to 01 January, 1970 UTC. + * + * The `Date` object provides uniform behavior across platforms. + * + * The `Date` object supports a number of UTC (universal) methods, as well as + * local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the + * time as set by the World Time Standard. The local time is the time known to the + * computer where JavaScript is executed. + * + * Invoking `Date` in a non-constructor context (i.e., without the `new` operator) + * will return a string representing the current time. + * + * Note that `Date` objects can only be instantiated by calling `Date` or using it + * as a constructor; unlike other JavaScript object types, `Date` objects have no + * literal syntax. + * + * # Several ways to assign dates + * + * The following example shows several ways to assign dates: + * + * today = new Date(); + * birthday = new Date("December 19, 1989 03:24:00"); + * birthday = new Date(1989,11,19); + * birthday = new Date(1989,11,17,3,24,0); + * + * # Calculating elapsed time + * + * The following examples show how to determine the elapsed time between two dates: + * + * // using static methods + * var start = Date.now(); + * // the event you'd like to time goes here: + * doSomethingForALongTime(); + * var end = Date.now(); + * var elapsed = end - start; // time in milliseconds + * + * // if you have Date objects + * var start = new Date(); + * // the event you'd like to time goes here: + * doSomethingForALongTime(); + * var end = new Date(); + * var elapsed = end.getTime() - start.getTime(); // time in milliseconds + * + * // if you want to test a function and get back its return + * function printElapsedTime (fTest) { + * var nStartTime = Date.now(), vReturn = fTest(), nEndTime = Date.now(); + * alert("Elapsed time: " + String(nEndTime - nStartTime) + " + * milliseconds"); + * return vReturn; + * } + * + * yourFunctionReturn = printElapsedTime(yourFunction); + * + * # ISO 8601 formatted dates + * + * The following example shows how to formate a date in an ISO 8601 format using + * UTC: + * + * // use a function for the exact format desired... + * function ISODateString(d){ + * function pad(n){return n<10 ? '0'+n : n} + * return d.getUTCFullYear()+'-' + * + pad(d.getUTCMonth()+1)+'-' + * + pad(d.getUTCDate())+'T' + * + pad(d.getUTCHours())+':' + * + pad(d.getUTCMinutes())+':' + * + pad(d.getUTCSeconds())+'Z'} + * + * var d = new Date(); + * print(ISODateString(d)); // prints something like 2009-09-28T19:03:12Z + * + * <div class="notice"> + * Documentation for this class comes from <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">MDN</a> + * and is available under <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons: Attribution-Sharealike license</a>. + * </div> + */ + +/** + * @method constructor + * Creates new Date object. + * + * @param {Number/String} [year] + * Either UNIX timestamp, date string, or year (when month and day parameters also provided): + * + * - Integer value representing the number of milliseconds since 1 January 1970 + * 00:00:00 UTC (Unix Epoch). + * + * - String value representing a date. The string should be in a format recognized + * by the parse method (IETF-compliant RFC 1123 timestamps). + * + * - Integer value representing the year. For compatibility (in order to avoid the + * Y2K problem), you should always specify the year in full; use 1998, rather + * than 98. + * + * @param {Number} [month] + * Integer value representing the month, beginning with 0 for January to 11 + * for December. + * @param {Number} [day] + * Integer value representing the day of the month (1-31). + * @param {Number} [hour] + * Integer value representing the hour of the day (0-23). + * @param {Number} [minute] + * Integer value representing the minute segment (0-59) of a time reading. + * @param {Number} [second] + * Integer value representing the second segment (0-59) of a time reading. + * @param {Number} [millisecond] + * Integer value representing the millisecond segment (0-999) of a time reading. + */ -// After dependencies have loaded: -function() { - var proto = this.prototype; - proto.monthNames = Ext.Date.monthNames; +//Methods - proto.dayNames = Ext.Date.dayNames; +/** + * @method now + * @static + * Returns the numeric value corresponding to the current time. + * + * The `now` method returns the milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now as + * a number. + * + * When using `now` to create timestamps or unique IDs, keep in mind that the resolution may be 15 + * milliseconds on Windows, so you could end up with several equal values if `now` is called multiple + * times within a short time span. + * + * @return {Number} Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + +/** + * @method parse + * @static + * Parses a string representation of a date, and returns the number of milliseconds + * since January 1, 1970, 00:00:00, local time. + * + * The `parse` method takes a date string (such as `"Dec 25, 1995"`) and returns the number of + * milliseconds since January 1, 1970, 00:00:00 UTC. The local time zone is used to interpret + * arguments that do not contain time zone information. This function is useful for setting date + * values based on string values, for example in conjunction with the `setTime` method and the + * {@link Date} object. + * + * Given a string representing a time, parse returns the time value. It accepts the IETF standard (RFC + * 1123 Section 5.2.14 and elsewhere) date syntax: `"Mon, 25 Dec 1995 13:30:00 GMT"`. It understands + * the continental US time-zone abbreviations, but for general use, use a time-zone offset, for + * example, `"Mon, 25 Dec 1995 13:30:00 GMT+0430"` (4 hours, 30 minutes east of the Greenwich + * meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are + * considered equivalent. + * + * ### Using parse + * + * If `IPOdate` is an existing `Date` object, then you can set it to August 9, 1995 (local time) as + * follows: + * + * IPOdate.setTime(Date.parse("Aug 9, 1995")); + * + * Some other examples: + * + * // Returns 807937200000 in time zone GMT-0300, and other values in other + * // timezones, since the argument does not specify a time zone. + * Date.parse("Aug 9, 1995"); + * + * // Returns 807926400000 no matter the local time zone. + * Date.parse("Wed, 09 Aug 1995 00:00:00 GMT"); + * + * // Returns 807937200000 in timezone GMT-0300, and other values in other + * // timezones, since there is no time zone specifier in the argument. + * Date.parse("Wed, 09 Aug 1995 00:00:00"); + * + * // Returns 0 no matter the local time zone. + * Date.parse("Thu, 01 Jan 1970 00:00:00 GMT"); + * + * // Returns 14400000 in timezone GMT-0400, and other values in other + * // timezones, since there is no time zone specifier in the argument. + * Date.parse("Thu, 01 Jan 1970 00:00:00"); + * + * // Returns 14400000 no matter the local time zone. + * Date.parse("Thu, 01 Jan 1970 00:00:00 GMT-0400"); + * + * @param {String} dateString A string representing a date. + * @return {Number} Number of milliseconds since January 1, 1970, 00:00:00, local time. + */ + +/** + * @method UTC + * @static + * Accepts the same parameters as the longest form of the constructor, and returns + * the number of milliseconds in a `Date` object since January 1, 1970, 00:00:00, + * universal time. + * + * `UTC` takes comma-delimited date parameters and returns the number of milliseconds between January + * 1, 1970, 00:00:00, universal time and the time you specified. + * + * You should specify a full year for the year; for example, 1998. If a year between 0 and 99 is + * specified, the method converts the year to a year in the 20th century (1900 + year); for example, + * if you specify 95, the year 1995 is used. + * + * The `UTC` method differs from the `Date` constructor in two ways. + * * `Date.UTC` uses universal time instead of the local time. + * * `Date.UTC` returns a time value as a number instead of creating a `Date` object. + * + * If a parameter you specify is outside of the expected range, the `UTC` method updates the other + * parameters to allow for your number. For example, if you use 15 for month, the year will be + * incremented by 1 (year + 1), and 3 will be used for the month. + * + * Because `UTC` is a static method of `Date`, you always use it as `Date.UTC()`, rather than as a + * method of a `Date` object you created. +* + * The following statement creates a `Date` object using GMT instead of local time: + * + * gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0)); + * + * @param {Number} year A year after 1900. + * @param {Number} month An integer between 0 and 11 representing the month. + * @param {Number} date An integer between 1 and 31 representing the day of the month. + * @param {Number} hrs An integer between 0 and 23 representing the hours. + * @param {Number} min An integer between 0 and 59 representing the minutes. + * @param {Number} sec An integer between 0 and 59 representing the seconds. + * @param {Number} ms An integer between 0 and 999 representing the milliseconds. + * @return {Date} Number of milliseconds since January 1, 1970, 00:00:00, universal time. + */ + +//Methods + +/** + * @method getDate + * Returns the numeric value corresponding to the current time. + * + * The second statement below assigns the value 25 to the variable `day`, based on the value of the + * `Date` object `Xmas95`. + * + * Xmas95 = new Date("December 25, 1995 23:15:00") + * day = Xmas95.getDate() + * + * @return {Number} Value between 1 and 31. + */ + +/** + * @method getDay + * Returns the numeric value corresponding to the current time. + * + * The value returned by `getDay` is an integer corresponding to the day of the week: 0 for Sunday, 1 + * for Monday, 2 for Tuesday, and so on. + * + * The second statement below assigns the value 1 to `weekday`, based on the value of the `Date` + * object `Xmas95`. December 25, 1995, is a Monday. + * + * Xmas95 = new Date("December 25, 1995 23:15:00"); + * weekday = Xmas95.getDay(); + * + * @return {Number} A numeric representation of the day from Sunday (0) to + * Saturday (6). + */ + +/** + * @method getFullYear + * Returns the numeric value corresponding to the current time. + * + * The value returned by `getFullYear` is an absolute number. For dates between the years 1000 and + * 9999, `getFullYear` returns a four-digit number, for example, 1995. Use this function to make sure + * a year is compliant with years after 2000. + * + * Use this method instead of the `getYear` method. + * + * The following example assigns the four-digit value of the current year to the variable yr. + * + * var today = new Date(); + * var yr = today.getFullYear(); + * + * @return {Number} Four digit representation of the year. + */ - proto.format = Ext.Date.defaultFormat; -}); -+/** + * @method getHours + * Returns the numeric value corresponding to the current time. + * + * The second statement below assigns the value 23 to the variable `hours`, based on the value of the + * `Date` object `Xmas95`. + * + * Xmas95 = new Date("December 25, 1995 23:15:00") + * hours = Xmas95.getHours() + * + * @return {Number} Value between 0 and 23, using 24-hour clock. + */ + +/** + * @method getMilliseconds + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the milliseconds portion of the current time to the variable ms. + * + * var ms; + * Today = new Date(); + * ms = Today.getMilliseconds(); + * + * @return {Number} A number between 0 and 999. + */ + +/** + * @method getMinutes + * Returns the numeric value corresponding to the current time. + * + * The second statement below assigns the value 15 to the variable `minutes`, based on the value of + * the `Date` object `Xmas95`. + * + * Xmas95 = new Date("December 25, 1995 23:15:00") + * minutes = Xmas95.getMinutes() + * + * @return {Number} Value between 0 and 59. + */ + +/** + * @method getMonth + * Returns the numeric value corresponding to the current time. + * + * The second statement below assigns the value 11 to the variable `month`, based on the value of the + * `Date` object `Xmas95`. + * + * Xmas95 = new Date("December 25, 1995 23:15:00") + * month = Xmas95.getMonth() + * + * @return {Number} An integer between 0 and 11. 0 corresponds to January, 1 to February, and so on. + */ + +/** + * @method getSeconds + * Returns the numeric value corresponding to the current time. + * + * The second statement below assigns the value 30 to the variable `secs`, based on the value of the + * `Date` object `Xmas95`. + * + * Xmas95 = new Date("December 25, 1995 23:15:30") + * secs = Xmas95.getSeconds() + * + * @return {Number} Value between 0 and 59. + */ + +/** + * @method getTime + * Returns the numeric value corresponding to the current time. + * + * The value returned by the `getTime` method is the number of milliseconds since 1 January 1970 + * 00:00:00 UTC. You can use this method to help assign a date and time to another `Date` object. + * + * This method is functionally equivalent to the `valueOf` method. + * + * Using getTime for copying dates + * + * Constructing a date object with the identical time value. + * + * var birthday = new Date(1994, 12, 10); + * var copy = new Date(); + * copy.setTime(birthday.getTime()); + * + * Measuring execution time + * + * Subtracting two subsequent getTime calls on newly generated Date objects, give the time span + * between these two calls. This can be used to calculate the executing time of some operations. + * + * var end, start; + * + * start = new Date(); + * for (var i = 0; i < 1000; i++) + * Math.sqrt(i); + * end = new Date(); + * + * console.log("Operation took " + (end.getTime() - start.getTime()) + " msec"); + * + * @return {Number} Number of milliseconds since 1/1/1970 (GMT). + */ + +/** + * @method getTimezoneOffset + * Returns the numeric value corresponding to the current time. + * + * The time-zone offset is the difference, in minutes, between UTC and local time. Note that this + * means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. + * For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned. + * Daylight savings time prevents this value from being a constant even for a given locale + * + * x = new Date() + * currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60 + * + * @return {Number} Minutes between GMT and local time. + */ + +/** + * @method getUTCDate + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the day portion of the current date to the variable `d`. + * + * var d; + * Today = new Date(); + * d = Today.getUTCDate(); + * + * @return {Number} Integer between 1 and 31 representing the day. + */ + +/** + * @method getUTCDay + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the weekday portion of the current date to the variable `weekday`. + * + * var weekday; + * Today = new Date() + * weekday = Today.getUTCDay() + * + * @return {Number} A numeric representation of the day from Sunday (0) to + * Saturday (6). + */ + +/** + * @method getUTCFullYear + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the four-digit value of the current year to the variable `yr`. + * + * var yr; + * Today = new Date(); + * yr = Today.getUTCFullYear(); + * + * @return {Number} Four digit representation of the year. + */ + +/** + * @method getUTCHours + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the hours portion of the current time to the variable `hrs`. + * + * var hrs; + * Today = new Date(); + * hrs = Today.getUTCHours(); + * + * @return {Number} Value between 0 and 23. + */ + +/** + * @method getUTCMilliseconds + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the milliseconds portion of the current time to the variable `ms`. + * + * var ms; + * Today = new Date(); + * ms = Today.getUTCMilliseconds(); + * + * @return {Number} Milliseconds portion of the Date. + */ + +/** + * @method getUTCMinutes + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the minutes portion of the current time to the variable `min`. + * + * var min; + * Today = new Date(); + * min = Today.getUTCMinutes(); + * + * @return {Number} Value between 0 and 59. + */ + +/** + * @method getUTCMonth + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the month portion of the current date to the variable `mon`. + * + * var mon; + * Today = new Date(); + * mon = Today.getUTCMonth(); + * + * @return {Number} Value between 0 (January) and 11 (December). +*/ + +/** + * @method getUTCSeconds + * Returns the numeric value corresponding to the current time. + * + * The following example assigns the seconds portion of the current time to the variable `sec`. + * + * var sec; + * Today = new Date(); + * sec = Today.getUTCSeconds(); + * + * @return {Number} Value between 0 and 59. +*/ + +/** + * @method setDate + * Sets the day of the month (1-31) for a specified date according to local time. + * + * If the parameter you specify is outside of the expected range, `setDate` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 0 for `dayValue`, the + * date will be set to the last day of the previous month. + * + * The second statement below changes the day for theBigDay to July 24 from its original value. + * + * theBigDay = new Date("July 27, 1962 23:30:00") + * theBigDay.setDate(24) + * + * @param {Number} dayValue An integer from 1 to 31, representing the day of the month. + * @return {Number} New date represented as milliseconds. +*/ + +/** + * @method setFullYear + * Sets the full year (4 digits for 4-digit years) for a specified date according to + * local time. + * + * If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the + * `getMonth` and `getDate` methods are used. + * + * If a parameter you specify is outside of the expected range, `setFullYear` attempts to update the + * other parameters and the date information in the `Date` object accordingly. For example, if you + * specify 15 for monthValue, the year is incremented by 1 (year + 1), and 3 is used for the month. + * + * theBigDay = new Date(); + * theBigDay.setFullYear(1997); + * + * @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995. + * @param {Number} monthValue An integer between 0 and 11 representing the months January through + * December. + * @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you + * specify the `dayValue` parameter, you must also specify the `monthValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setHours + * Sets the hours (0-23) for a specified date according to local time. + * + * If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values + * returned from the `getUTCMinutes`, `getUTCSeconds`, and `getMilliseconds` methods are used. + * + * If a parameter you specify is outside of the expected range, setHours attempts to update the date + * information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, the + * minutes will be incremented by 1 (min + 1), and 40 will be used for seconds. + * + * theBigDay.setHours(7) + * + * @param {Number} hoursValue An integer between 0 and 23, representing the hour. + * @param {Number} minutesValue An integer between 0 and 59, representing the minutes. + * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the + * `secondsValue` parameter, you must also specify the `minutesValue`. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the + * `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setMilliseconds + * Sets the milliseconds (0-999) for a specified date according to local time. + * + * If you specify a number outside the expected range, the date information in the `Date` object is + * updated accordingly. For example, if you specify 1005, the number of seconds is incremented by 1, + * and 5 is used for the milliseconds. + * + * theBigDay = new Date(); + * theBigDay.setMilliseconds(100); + * + * @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setMinutes + * Sets the minutes (0-59) for a specified date according to local time. + * + * If you do not specify the `secondsValue` and `msValue` parameters, the values returned from + * `getSeconds` and `getMilliseconds` methods are used. + * + * If a parameter you specify is outside of the expected range, `setMinutes` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, + * the minutes (`minutesValue`) will be incremented by 1 (minutesValue + 1), and 40 will be used for + * seconds. + * + * theBigDay.setMinutes(45) + * + * @param {Number} minutesValue An integer between 0 and 59, representing the minutes. + * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you + * specify the secondsValue parameter, you must also specify the `minutesValue`. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify + * the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setMonth + * Sets the month (0-11) for a specified date according to local time. + * + * If you do not specify the `dayValue` parameter, the value returned from the `getDate` method is + * used. + * + * If a parameter you specify is outside of the expected range, `setMonth` attempts to update the date + * information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the year + * will be incremented by 1 (year + 1), and 3 will be used for month. + * + * theBigDay.setMonth(6) + * + * @param {Number} monthValue An integer between 0 and 11 (representing the months January through + * December). + * @param {Number} dayValue An integer from 1 to 31, representing the day of the month. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setSeconds + * Sets the seconds (0-59) for a specified date according to local time. + * + * If you do not specify the `msValue` parameter, the value returned from the `getMilliseconds` method + * is used. + * + * If a parameter you specify is outside of the expected range, `setSeconds` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, + * the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds. + * + * theBigDay.setSeconds(30) + * + * @param {Number} secondsValue An integer between 0 and 59. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify + * the`msValue` parameter, you must also specify the `minutesValue` and `secondsValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setTime + * Sets the Date object to the time represented by a number of milliseconds since + * January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior. + * + * Use the `setTime` method to help assign a date and time to another `Date` object. + * + * theBigDay = new Date("July 1, 1999") + * sameAsBigDay = new Date() + * sameAsBigDay.setTime(theBigDay.getTime()) + * + * @param {Number} timeValue An integer representing the number of milliseconds since 1 January + * 1970, 00:00:00 UTC. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCDate + * Sets the day of the month (1-31) for a specified date according to universal time. + * + * If a parameter you specify is outside of the expected range, `setUTCDate` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 40 for `dayValue`, and + * the month stored in the `Date` object is June, the day will be changed to 10 and the month will be + * incremented to July. + * + * theBigDay = new Date(); + * theBigDay.setUTCDate(20); + * + * @param {Number} dayValue An integer from 1 to 31, representing the day of the month. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCFullYear + * Sets the full year (4 digits for 4-digit years) for a specified date according + * to universal time. + * + * If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the + * `getMonth` and `getDate` methods are used. + * + * If a parameter you specify is outside of the expected range, `setUTCFullYear` attempts to update + * the other parameters and the date information in the `Date` object accordingly. For example, if you + * specify 15 for `monthValue`, the year is incremented by 1 (year + 1), and 3 is used for the month. + * + * theBigDay = new Date(); + * theBigDay.setUTCFullYear(1997); + * + * @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995. + * @param {Number} monthValue An integer between 0 and 11 representing the months January through + * December. + * @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you + * specify the `dayValue` parameter, you must also specify the `monthValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCHours + * Sets the hour (0-23) for a specified date according to universal time. + * + * If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values + * returned from the `getUTCMinutes`, `getUTCSeconds`, and `getUTCMilliseconds` methods are used. + * + * If a parameter you specify is outside of the expected range, `setUTCHours` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, + * the minutes will be incremented by 1 (min + 1), and 40 will be used for seconds. + * + * theBigDay = new Date(); + * theBigDay.setUTCHours(8); + * + * @param {Number} hoursValue An integer between 0 and 23, representing the hour. + * @param {Number} minutesValue An integer between 0 and 59, representing the minutes. + * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the + * `secondsValue` parameter, you must also specify the `minutesValue`. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the + * `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCMilliseconds + * Sets the milliseconds (0-999) for a specified date according to universal time. + * + * If a parameter you specify is outside of the expected range, `setUTCMilliseconds` attempts to + * update the date information in the `Date` object accordingly. For example, if you use 1100 for + * `millisecondsValue`, the seconds stored in the Date object will be incremented by 1, and 100 will + * be used for milliseconds. + * + * theBigDay = new Date(); + * theBigDay.setUTCMilliseconds(500); + * + * @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCMinutes + * Sets the minutes (0-59) for a specified date according to universal time. + * + * If you do not specify the `secondsValue` and `msValue` parameters, the values returned from + * `getUTCSeconds` and `getUTCMilliseconds` methods are used. + * + * If a parameter you specify is outside of the expected range, `setUTCMinutes` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, + * the minutes (`minutesValue`) will be incremented by 1 (`minutesValue` + 1), and 40 will be used for + * seconds. + * + * theBigDay = new Date(); + * theBigDay.setUTCMinutes(43); + * + * @param {Number} minutesValue An integer between 0 and 59, representing the minutes. + * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the `secondsValue` parameter, you must also specify the `minutesValue`. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCMonth + * Sets the month (0-11) for a specified date according to universal time. + * + * If you do not specify the `dayValue` parameter, the value returned from the `getUTCDate` method is + * used. + * + * If a parameter you specify is outside of the expected range, `setUTCMonth` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the + * year will be incremented by 1 (year + 1), and 3 will be used for month. + * + * theBigDay = new Date(); + * theBigDay.setUTCMonth(11); + * + * @param {Number} monthValue An integer between 0 and 11, representing the months January through + * December. + * @param {Number} dayValue An integer from 1 to 31, representing the day of the month. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method setUTCSeconds + * Sets the seconds (0-59) for a specified date according to universal time. + * + * If you do not specify the `msValue` parameter, the value returned from the `getUTCMilliseconds` + * methods is used. + * + * If a parameter you specify is outside of the expected range, `setUTCSeconds` attempts to update the + * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, + * the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds. + * + * theBigDay = new Date(); + * theBigDay.setUTCSeconds(20); + * + * @param {Number} secondsValue An integer between 0 and 59. + * @param {Number} msValue A number between 0 and 999, representing the milliseconds. + * @return {Number} New date represented as milliseconds. + */ + +/** + * @method toDateString + * Returns the "date" portion of the Date as a human-readable string in American English. + * + * {@link Date} instances refer to a specific point in time. Calling `toString` will return the + * date formatted in a human readable form in American English. In SpiderMonkey, this consists of the + * date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and time + * zone). Sometimes it is desirable to obtain a string of the date portion; such a thing can be + * accomplished with the `toDateString` method. + * + * The `toDateString` method is especially useful because compliant engines implementing ECMA-262 may + * differ in the string obtained from `toString` for `Date` objects, as the format is implementation- + * dependent and simple string slicing approaches may not produce consistent results across multiple + * engines. + * + * var d = new Date(1993, 6, 28, 14, 39, 7); + * println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) + * println(d.toDateString()); // prints Wed Jul 28 1993 + * + * @return {String} Human-readable string, in local time. + */ + +/** + * @method toLocaleDateString + * Returns the "date" portion of the Date as a string, using the current locale's + * conventions. + * + * The `toLocaleDateString` method relies on the underlying operating system in formatting dates. It + * converts the date to a string using the formatting convention of the operating system where the + * script is running. For example, in the United States, the month appears before the date (04/15/98), + * whereas in Germany the date appears before the month (15.04.98). If the operating system is not + * year-2000 compliant and does not use the full year for years before 1900 or over 2000, + * `toLocaleDateString` returns a string that is not year-2000 compliant. `toLocaleDateString` behaves + * similarly to `toString` when converting a year that the operating system does not properly format. + * + * Methods such as `getDate`, `getMonth`, and `getFullYear` give more portable results than + * `toLocaleDateString`. Use `toLocaleDateString` when the intent is to display to the user a string + * formatted using the regional format chosen by the user. Be aware that this method, due to its + * nature, behaves differently depending on the operating system and on the user's settings. + * + * In the following example, `today` is a `Date` object: + * + * today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11 + * today.toLocaleDateString() + * + * In this example, `toLocaleDateString` returns a string value that is similar to the following form. + * The exact format depends on the platform, locale and user's settings. + * + * 12/18/95 + * + * You shouldn't use this method in contexts where you rely on a particular format or locale. + * + * "Last visit: " + someDate.toLocaleDateString(); // Good example + * "Last visit was at " + someDate.toLocaleDateString(); // Bad example + * + * @return {String} Human-readable string that may be formatted differently depending + * on the country. + */ + +/** + * @method toLocaleString + * Converts a date to a string, using the current locale's conventions. Overrides + * the `Object.toLocaleString` method. + * + * The `toLocaleString` method relies on the underlying operating system in formatting dates. It + * converts the date to a string using the formatting convention of the operating system where the + * script is running. For example, in the United States, the month appears before the date (04/15/98), + * whereas in Germany the date appears before the month (15.04.98). If the operating system is not + * year-2000 compliant and does not use the full year for years before 1900 or over 2000, + * `toLocaleString` returns a string that is not year-2000 compliant. `toLocaleString` behaves + * similarly to `toString` when converting a year that the operating system does not properly format. + * + * Methods such as `getDate`, `getMonth`, `getFullYear`, `getHours`, `getMinutes`, and `getSeconds` + * give more portable results than `toLocaleString`. Use `toLocaleString` when the intent is to + * display to the user a string formatted using the regional format chosen by the user. Be aware that + * this method, due to its nature, behaves differently depending on the operating system and on the + * user's settings. + * + * In the following example, `today` is a `Date` object: + * + * today = new Date(95,11,18,17,28,35); //months are represented by 0 to 11 + * today.toLocaleString(); + * + * In this example, `toLocaleString` returns a string value that is similar to the following form. The + * exact format depends on the platform, locale and user's settings. + * + * 12/18/95 17:28:35 + * + * You shouldn't use this method in contexts where you rely on a particular format or locale. + * + * "Last visit: " + someDate.toLocaleString(); // Good example + * "Last visit was at " + someDate.toLocaleString(); // Bad example + * + * @return {String} Human-readable string that may be formatted differently depending + * on the country. + */ + +/** + * @method toLocaleTimeString + * Returns the "time" portion of the Date as a string, using the current locale's + * conventions. + * + * The `toLocaleTimeString` method relies on the underlying operating system in formatting dates. It + * converts the date to a string using the formatting convention of the operating system where the + * script is running. For example, in the United States, the month appears before the date (04/15/98), + * whereas in Germany the date appears before the month (15.04.98). + * + * Methods such as `getHours`, `getMinutes`, and `getSeconds` give more consistent results than + * `toLocaleTimeString`. Use `toLocaleTimeString` when the intent is to display to the user a string + * formatted using the regional format chosen by the user. Be aware that this method, due to its + * nature, behaves differently depending on the operating system and on the user's settings. + * + * In the following example, `today` is a `Date` object: + * + * today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11 + * today.toLocaleTimeString() + * + * In this example, `toLocaleTimeString` returns a string value that is similar to the following form. + * The exact format depends on the platform. + * + * 17:28:35 + * + * You shouldn't use this method in contexts where you rely on a particular format or locale. + * + * "Last visit: " + someDate.toLocaleTimeString(); // Good example + * "Last visit was at " + someDate.toLocaleTimeString(); // Bad example + * + * @return {String} Human-readable string that may be formatted differently depending + * on the country. + */ + +/** + * @method toString + * Returns a string representing the specified Date object. Overrides the + * `Object.prototype.toString` method. + * + * The `Date` object overrides the toString method of the Object object; it does not inherit + * `Object.toString`. For `Date` objects, the `toString` method returns a string representation of the + * object. + * + * `toString` always returns a string representation of the date in American English. + * + * JavaScript calls the `toString` method automatically when a date is to be represented as a text + * value or when a date is referred to in a string concatenation. + * + * The following assigns the `toString` value of a `Date` object to `myVar`: + * + * x = new Date(); + * myVar=x.toString(); //assigns a value to myVar similar to: + * //Mon Sep 28 1998 14:36:22 GMT-0700 (Pacific Daylight Time) + * + * @return {String} Human-readable string of the date in local time. + */ + +/** + * @method toTimeString + * Returns the "time" portion of the Date as a human-readable string. + * + * {@link Date} instances refer to a specific point in time. Calling `toString` will return the + * date formatted in a human readable form in American English. In SpiderMonkey, this consists of the + * date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and + * time zone). Sometimes it is desirable to obtain a string of the time portion; such a thing can be + * accomplished with the `toTimeString` method. + * + * The `toTimeString` method is especially useful because compliant engines implementing ECMA-262 may + * differ in the string obtained from `toString` for `Date` objects, as the format is implementation- + * dependent; simple string slicing approaches may not produce consistent results across multiple + * engines. + * + * var d = new Date(1993, 6, 28, 14, 39, 7); + * println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) + * println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT) + * + * @return {String} Human-readable string of the date in local time. + */ + +/** + * @method toUTCString + * Converts a date to a string, using the universal time convention. + * + * The value returned by `toUTCString` is a readable string in American English in the UTC time zone. + * The format of the return value may vary according to the platform. + * + * var today = new Date(); + * var UTCstring = today.toUTCString(); + * // Mon, 03 Jul 2006 21:44:38 GMT + * + * @return {String} String of the date in UTC. + */ + +/** + * @method valueOf + * Returns the primitive value of a Date object. Overrides the + * Object.prototype.valueOf method. + * + * The `valueOf` method returns the primitive value of a `Date` object as a number data type, the + * number of milliseconds since midnight 01 January, 1970 UTC. + * + * This method is functionally equivalent to the `getTime` method. + * + * This method is usually called internally by JavaScript and not explicitly in code. + * + * x = new Date(56, 6, 17); + * myVar = x.valueOf(); //assigns -424713600000 to myVar + * + * @return {Number} Date represented as milliseconds. + */