class type t =object
..end
method _DAY : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "d"
method _HOUR : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "h"
method _MILLI : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "ms"
method _MINUTE : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "mi"
method _MONTH : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "mo"
method _SECOND : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "s"
method _YEAR : Js.js_string Js.t Js.prop
Date interval constant
Defaults to: "y"
method dayNames : Js.js_string Js.t Js.js_array Js.t Js.prop
An array of textual day names. Override these values for international dates.
Example:
Ext.Date.dayNames = [
'SundayInYourLang',
'MondayInYourLang'
// ...
];
Defaults to: ''Sunday'', ''Monday'', ''Tuesday'', ''Wednesday'', ''Thursday'', ''Friday'', ''Saturday''
method defaultFormat : Js.js_string Js.t Js.prop
The date format string that the Ext.util.Format.dateRenderer and Ext.util.Format.date functions use. See Ext.Date for details.
This may be overridden in a locale file.
Defaults to: "m/d/Y"
method defaults : 'a. 'a Js.t Js.prop
An object hash containing default date values used during date parsing.
The following properties are available:
y
: Numberm
: Numberd
: Numberh
: Numberi
: Numbers
: Numberms
: NumberOverride these properties to customize the default date values used by the parse method.
Note: In countries which experience Daylight Saving Time (i.e. DST), the h
, i
, s
and ms
properties may coincide with the exact time in which DST takes effect.
It is the responsibility of the developer to account for this.
Example Usage:
// set default day value to the first day of the month
Ext.Date.defaults.d = 1;
// parse a February date string containing only year and month values.
// setting the default day value to 1 prevents weird date rollover issues
// when attempting to parse the following date string on, for example, March 31st 2009.
Ext.Date.parse('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
Defaults to: {}
method formatCodes : 'b. 'b Js.t Js.prop
The base format-code to formatting-function hashmap used by the format method. Formatting functions are strings (or functions which return strings) which will return the appropriate value when evaluated in the context of the Date object from which the format method is called. Add to / override these mappings for custom date formatting.
Note: Ext.Date.format() treats characters as literals if an appropriate mapping cannot be found.
Example:
Ext.Date.formatCodes.x = "Ext.util.Format.leftPad(this.getDate(), 2, '0')";
console.log(Ext.Date.format(new Date(), 'X'); // returns the current day of the month
method formatFunctions : 'c. 'c Js.t Js.prop
An object hash in which each property is a date formatting function. The property name is the format string which corresponds to the produced formatted date string.
This object is automatically populated with date formatting functions as date formats are requested for Ext standard formatting strings.
Custom formatting functions may be inserted into this object, keyed by a name which from then on may be used as a format string to format.
Example:
Ext.Date.formatFunctions['x-date-format'] = myDateFormatter;
A formatting function should return a string representation of the passed Date object, and is passed the following parameters:
date
: DateTo enable date strings to also be parsed according to that format, a corresponding parsing function must be placed into the parseFunctions property.
method monthNames : Js.js_string Js.t Js.js_array Js.t Js.prop
An array of textual month names. Override these values for international dates.
Example:
Ext.Date.monthNames = [
'JanInYourLang',
'FebInYourLang'
// ...
];
Defaults to: ''January'', ''February'', ''March'', ''April'', ''May'', ''June'', ''July'', ''August'', ''September'', ''October'', ''November'', ''December''
method monthNumbers : 'd. 'd Js.t Js.prop
An object hash of zero-based JavaScript month numbers (with short month names as keys. Note: keys are case-sensitive). Override these values for international dates.
Example:
Ext.Date.monthNumbers = {
'LongJanNameInYourLang': 0,
'ShortJanNameInYourLang':0,
'LongFebNameInYourLang':1,
'ShortFebNameInYourLang':1
// ...
};
Defaults to: {January: 0, Jan: 0, February: 1, Feb: 1, March: 2, Mar: 2, April: 3, Apr: 3, May: 4, June: 5, Jun: 5, July: 6, Jul: 6, August: 7, Aug: 7, September: 8, Sep: 8, October: 9, Oct: 9, November: 10, Nov: 10, December: 11, Dec: 11}
method parseFunctions : 'e. 'e Js.t Js.prop
An object hash in which each property is a date parsing function. The property name is the format string which that function parses.
This object is automatically populated with date parsing functions as date formats are requested for Ext standard formatting strings.
Custom parsing functions may be inserted into this object, keyed by a name which from then on may be used as a format string to parse.
Example:
Ext.Date.parseFunctions['x-date-format'] = myDateParser;
A parsing function should return a Date object, and is passed the following parameters:
date
: Stringstrict
: Booleanfalse
).
Invalid date strings should return null
when parsed.To enable Dates to also be formatted according to that format, a corresponding formatting function must be placed into the formatFunctions property.
method useStrict : bool Js.t Js.prop
Global flag which determines if strict date parsing should be used. Strict date parsing will not roll-over invalid dates, which is the default behavior of JavaScript Date objects. (see parse for more information)
Defaults to: false
method add : Js.date Js.t -> Js.js_string Js.t -> Js.number Js.t -> Js.date Js.t Js.meth
Provides a convenient method for performing basic date arithmetic. This method does not modify the Date instance being called - it creates and returns a new Date instance containing the resulting date value.
Examples:
// Basic usage:
var dt = Ext.Date.add(new Date('10/29/2006'), Ext.Date.DAY, 5);
console.log(dt); // returns 'Fri Nov 03 2006 00:00:00'
// Negative values will be subtracted:
var dt2 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, -5);
console.log(dt2); // returns 'Tue Sep 26 2006 00:00:00'
// Decimal values can be used:
var dt3 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, 1.25);
console.log(dt3); // returns 'Mon Oct 02 2006 06:00:00'
Parameters:
Js.date Js.t
The date to modify
Js.js_string Js.t
A valid date interval enum value.
Js.number Js.t
The amount to add to the current date.
Returns:
Js.date Js.t
The new Date instance.
method between : Js.date Js.t -> Js.date Js.t -> Js.date Js.t -> bool Js.t Js.meth
Checks if a date falls on or between the given start and end dates.
Parameters:
Js.date Js.t
The date to check
Js.date Js.t
Start date
Js.date Js.t
End date
Returns:
bool Js.t
true
if this date falls on or between the given start and end dates.
method clearTime : Js.date Js.t -> bool Js.t Js.optdef -> Js.date Js.t Js.meth
Attempts to clear all time information from this Date by setting the time to midnight of the same day, automatically adjusting for Daylight Saving Time (DST) where applicable.
Note: DST timezone information for the browser's host operating system is assumed to be up-to-date.
Parameters:
Js.date Js.t
The date
bool Js.t
(optional)
true
to create a clone of this date, clear the time and return it.
Returns:
Js.date Js.t
this or the clone.
method clone : Js.date Js.t -> Js.date Js.t Js.meth
Creates and returns a new Date instance with the exact same date value as the called instance. Dates are copied and passed by reference, so if a copied date variable is modified later, the original variable will also be changed. When the intention is to create a new variable that will not modify the original instance, you should create a clone.
Example of correctly cloning a date:
//wrong way:
var orig = new Date('10/1/2006');
var copy = orig;
copy.setDate(5);
console.log(orig); // returns 'Thu Oct 05 2006'!
//correct way:
var orig = new Date('10/1/2006'),
copy = Ext.Date.clone(orig);
copy.setDate(5);
console.log(orig); // returns 'Thu Oct 01 2006'
Parameters:
Js.date Js.t
The date.
Returns:
Js.date Js.t
The new Date instance.
method format : Js.date Js.t -> Js.js_string Js.t -> Js.js_string Js.t Js.meth
Formats a date given the supplied format string.
Parameters:
Js.date Js.t
The date to format
Js.js_string Js.t
The format string
Returns:
Js.js_string Js.t
The formatted date or an empty string if date parameter is not a JavaScript Date object
method formatContainsDateInfo : Js.js_string Js.t -> bool Js.t Js.meth
Checks if the specified format contains information about anything other than the time.
Parameters:
Js.js_string Js.t
The format to check
Returns:
bool Js.t
True if the format contains information about date/day information.
method formatContainsHourInfo : Js.js_string Js.t -> bool Js.t Js.meth
Checks if the specified format contains hour information
Parameters:
Js.js_string Js.t
The format to check
Returns:
bool Js.t
True if the format contains hour information
method getDayOfYear : Js.date Js.t -> Js.number Js.t Js.meth
Get the numeric day number of the year, adjusted for leap year.
Parameters:
Js.date Js.t
The date
Returns:
Js.number Js.t
0 to 364 (365 in leap years).
method getDaysInMonth : Js.date Js.t -> Js.number Js.t Js.meth
Get the number of days in the current month, adjusted for leap year.
Parameters:
Js.date Js.t
The date
Returns:
Js.number Js.t
The number of days in the month.
method getElapsed : Js.date Js.t -> Js.date Js.t Js.optdef -> Js.number Js.t Js.meth
Returns the number of milliseconds between two dates.
Parameters:
Js.date Js.t
The first date.
Js.date Js.t
(optional) The second date.
Defaults to: new Date()Returns:
Js.number Js.t
The difference in milliseconds
method getFirstDateOfMonth : Js.date Js.t -> Js.date Js.t Js.meth
Get the date of the first day of the month in which this date resides.
Parameters:
Js.date Js.t
The date
method getFirstDayOfMonth : Js.date Js.t -> Js.number Js.t Js.meth
Get the first day of the current month, adjusted for leap year. The returned value is the numeric day index within the week (0-6) which can be used in conjunction with the monthNames array to retrieve the textual day name.
Example:
var dt = new Date('1/10/2007'),
firstDay = Ext.Date.getFirstDayOfMonth(dt);
console.log(Ext.Date.dayNames[firstDay]); // output: 'Monday'
Parameters:
Js.date Js.t
The date
Returns:
Js.number Js.t
The day number (0-6).
method getGMTOffset : Js.date Js.t -> bool Js.t Js.optdef -> Js.js_string Js.t Js.meth
Get the offset from GMT of the current date (equivalent to the format specifier 'O').
Parameters:
Js.date Js.t
The date
bool Js.t
(optional)
true to separate the hours and minutes with a colon.
Defaults to: falseReturns:
Js.js_string Js.t
The 4-character offset string prefixed with + or - (e.g. '-0600').
method getLastDateOfMonth : Js.date Js.t -> Js.date Js.t Js.meth
Get the date of the last day of the month in which this date resides.
Parameters:
Js.date Js.t
The date
method getLastDayOfMonth : Js.date Js.t -> Js.number Js.t Js.meth
Get the last day of the current month, adjusted for leap year. The returned value is the numeric day index within the week (0-6) which can be used in conjunction with the monthNames array to retrieve the textual day name.
Example:
var dt = new Date('1/10/2007'),
lastDay = Ext.Date.getLastDayOfMonth(dt);
console.log(Ext.Date.dayNames[lastDay]); // output: 'Wednesday'
Parameters:
Js.date Js.t
The date
Returns:
Js.number Js.t
The day number (0-6).
method getMonthNumber : Js.js_string Js.t -> Js.number Js.t Js.meth
Get the zero-based JavaScript month number for the given short/full month name. Override this function for international dates.
Parameters:
Js.js_string Js.t
The short/full month name.
Returns:
Js.number Js.t
The zero-based JavaScript month number.
method getShortDayName : Js.number Js.t -> Js.js_string Js.t Js.meth
Get the short day name for the given day number. Override this function for international dates.
Parameters:
Js.number Js.t
A zero-based JavaScript day number.
Returns:
Js.js_string Js.t
The short day name.
method getShortMonthName : Js.number Js.t -> Js.js_string Js.t Js.meth
Get the short month name for the given month number. Override this function for international dates.
Parameters:
Js.number Js.t
A zero-based JavaScript month number.
Returns:
Js.js_string Js.t
The short month name.
method getSuffix : Js.date Js.t -> Js.js_string Js.t Js.meth
Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
Parameters:
Js.date Js.t
The date
Returns:
Js.js_string Js.t
'st, 'nd', 'rd' or 'th'.
method getTimezone : Js.date Js.t -> Js.js_string Js.t Js.meth
Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').
Note: The date string returned by the JavaScript Date object's toString()
method varies
between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America).
For a given date string e.g. "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)",
getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses
(which may or may not be present), failing which it proceeds to get the timezone abbreviation
from the GMT offset portion of the date string.
Parameters:
Js.date Js.t
The date
Returns:
Js.js_string Js.t
The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).
method getWeekOfYear : Js.date Js.t -> Js.number Js.t Js.meth
Get the numeric ISO-8601 week number of the year. (equivalent to the format specifier 'W', but without a leading zero).
Parameters:
Js.date Js.t
The date
Returns:
Js.number Js.t
1 to 53
method isDST : Js.date Js.t -> bool Js.t Js.meth
Checks if the current date is affected by Daylight Saving Time (DST).
Parameters:
Js.date Js.t
The date
Returns:
bool Js.t
true
if the current date is affected by DST.
method isEqual : Js.date Js.t -> Js.date Js.t -> bool Js.t Js.meth
Compares if two dates are equal by comparing their values.
Parameters:
Js.date Js.t
Js.date Js.t
Returns:
bool Js.t
true
if the date values are equal
method isLeapYear : Js.date Js.t -> bool Js.t Js.meth
Checks if the current date falls within a leap year.
Parameters:
Js.date Js.t
The date
Returns:
bool Js.t
True if the current date falls within a leap year, false otherwise.
method isValid : Js.number Js.t ->
Js.number Js.t ->
Js.number Js.t ->
Js.number Js.t Js.optdef ->
Js.number Js.t Js.optdef ->
Js.number Js.t Js.optdef -> Js.number Js.t Js.optdef -> bool Js.t Js.meth
Checks if the passed Date parameters will cause a JavaScript Date "rollover".
Parameters:
Js.number Js.t
4-digit year
Js.number Js.t
1-based month-of-year
Js.number Js.t
Day of month
Js.number Js.t
(optional)
Hour
Js.number Js.t
(optional)
Minute
Js.number Js.t
(optional)
Second
Js.number Js.t
(optional)
Millisecond
Returns:
bool Js.t
true
if the passed parameters do not cause a Date "rollover", false
otherwise.
method now : Js.number Js.t Js.meth
Returns the current timestamp.
Returns:
Js.number Js.t
Milliseconds since UNIX epoch.
method parse : Js.js_string Js.t ->
Js.js_string Js.t -> bool Js.t Js.optdef -> Js.date Js.t Js.meth
Parses the passed string using the specified date format. Note that this function expects normal calendar dates, meaning that months are 1-based (i.e. 1 = January). The defaults hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond) which cannot be found in the passed string. If a corresponding default date value has not been specified in the defaults hash, the current date's year, month, day or DST-adjusted zero-hour time value will be used instead. Keep in mind that the input date string must precisely match the specified format string in order for the parse operation to be successful (failed parse operations return a null value).
Example:
//dt = Fri May 25 2007 (current date)
var dt = new Date();
//dt = Thu May 25 2006 (today's month/day in 2006)
dt = Ext.Date.parse("2006", "Y");
//dt = Sun Jan 15 2006 (all date parts specified)
dt = Ext.Date.parse("2006-01-15", "Y-m-d");
//dt = Sun Jan 15 2006 15:20:01
dt = Ext.Date.parse("2006-01-15 3:20:01 PM", "Y-m-d g:i:s A");
// attempt to parse Sun Feb 29 2006 03:20:01 in strict mode
dt = Ext.Date.parse("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
Parameters:
Js.js_string Js.t
The raw date string.
Js.js_string Js.t
The expected date string format.
bool Js.t
(optional)
true
to validate date strings while parsing (i.e. prevents JavaScript Date "rollover").
Invalid date strings will return null
when parsed.
Returns:
Js.date Js.t
The parsed Date.
method subtract : Js.date Js.t -> Js.js_string Js.t -> Js.number Js.t -> Js.date Js.t Js.meth
Provides a convenient method for performing basic date arithmetic. This method does not modify the Date instance being called - it creates and returns a new Date instance containing the resulting date value.
Examples:
// Basic usage:
var dt = Ext.Date.subtract(new Date('10/29/2006'), Ext.Date.DAY, 5);
console.log(dt); // returns 'Tue Oct 24 2006 00:00:00'
// Negative values will be added:
var dt2 = Ext.Date.subtract(new Date('10/1/2006'), Ext.Date.DAY, -5);
console.log(dt2); // returns 'Fri Oct 6 2006 00:00:00'
// Decimal values can be used:
var dt3 = Ext.Date.subtract(new Date('10/1/2006'), Ext.Date.DAY, 1.25);
console.log(dt3); // returns 'Fri Sep 29 2006 06:00:00'
Parameters:
Js.date Js.t
The date to modify
Js.js_string Js.t
A valid date interval enum value.
Js.number Js.t
The amount to subtract from the current date.
Returns:
Js.date Js.t
The new Date instance.
method unescapeFormat : Js.js_string Js.t -> Js.js_string Js.t Js.meth
Removes all escaping for a date format string. In date formats, using a '\' can be used to escape special characters.
Parameters:
Js.js_string Js.t
The format to unescape
Returns:
Js.js_string Js.t
The unescaped format