Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / core / src / lang / Date.js
index b59d193..0fefc30 100644 (file)
@@ -1,3 +1,17 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @class Ext.Date
  * A set of useful static methods to deal with date
 /**
  * @class Ext.Date
  * A set of useful static methods to deal with date
@@ -131,6 +145,7 @@ Ext.Date = {
     /**
      * Returns the current timestamp
      * @return {Date} The current timestamp
     /**
      * Returns the current timestamp
      * @return {Date} The current timestamp
+     * @method
      */
     now: Date.now || function() {
         return +new Date();
      */
     now: Date.now || function() {
         return +new Date();
@@ -167,7 +182,6 @@ Ext.Date = {
      * default behaviour of javascript Date objects.
      * (see {@link #parse} for more information)
      * Defaults to <tt>false</tt>.
      * default behaviour of javascript Date objects.
      * (see {@link #parse} for more information)
      * Defaults to <tt>false</tt>.
-     * @static
      * @type Boolean
     */
     useStrict: false,
      * @type Boolean
     */
     useStrict: false,
@@ -210,7 +224,6 @@ Ext.Date.parseFunctions['x-date-format'] = myDateParser;
      * <p>To enable Dates to also be <i>formatted</i> according to that format, a corresponding
      * formatting function must be placed into the {@link #formatFunctions} property.
      * @property parseFunctions
      * <p>To enable Dates to also be <i>formatted</i> according to that format, a corresponding
      * formatting function must be placed into the {@link #formatFunctions} property.
      * @property parseFunctions
-     * @static
      * @type Object
      */
     parseFunctions: {
      * @type Object
      */
     parseFunctions: {
@@ -239,7 +252,6 @@ Ext.Date.formatFunctions['x-date-format'] = myDateFormatter;
      * <p>To enable date strings to also be <i>parsed</i> according to that format, a corresponding
      * parsing function must be placed into the {@link #parseFunctions} property.
      * @property formatFunctions
      * <p>To enable date strings to also be <i>parsed</i> according to that format, a corresponding
      * parsing function must be placed into the {@link #parseFunctions} property.
      * @property formatFunctions
-     * @static
      * @type Object
      */
     formatFunctions: {
      * @type Object
      */
     formatFunctions: {
@@ -253,48 +265,41 @@ Ext.Date.formatFunctions['x-date-format'] = myDateFormatter;
 
     /**
      * Date interval constant
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     MILLI : "ms",
 
     /**
      * Date interval constant
      * @type String
      */
     MILLI : "ms",
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     SECOND : "s",
 
     /**
      * Date interval constant
      * @type String
      */
     SECOND : "s",
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     MINUTE : "mi",
 
     /** Date interval constant
      * @type String
      */
     MINUTE : "mi",
 
     /** Date interval constant
-     * @static
      * @type String
      */
     HOUR : "h",
 
     /**
      * Date interval constant
      * @type String
      */
     HOUR : "h",
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     DAY : "d",
 
     /**
      * Date interval constant
      * @type String
      */
     DAY : "d",
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     MONTH : "mo",
 
     /**
      * Date interval constant
      * @type String
      */
     MONTH : "mo",
 
     /**
      * Date interval constant
-     * @static
      * @type String
      */
     YEAR : "y",
      * @type String
      */
     YEAR : "y",
@@ -325,12 +330,12 @@ Ext.Date.defaults.d = 1;
 Ext.Date.parse('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
 </code></pre>
      * @property defaults
 Ext.Date.parse('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
 </code></pre>
      * @property defaults
-     * @static
      * @type Object
      */
     defaults: {},
 
     /**
      * @type Object
      */
     defaults: {},
 
     /**
+     * @property {String[]} dayNames
      * An array of textual day names.
      * Override these values for international dates.
      * Example:
      * An array of textual day names.
      * Override these values for international dates.
      * Example:
@@ -341,8 +346,6 @@ Ext.Date.dayNames = [
     ...
 ];
 </code></pre>
     ...
 ];
 </code></pre>
-     * @type Array
-     * @static
      */
     dayNames : [
         "Sunday",
      */
     dayNames : [
         "Sunday",
@@ -355,6 +358,7 @@ Ext.Date.dayNames = [
     ],
 
     /**
     ],
 
     /**
+     * @property {String[]} monthNames
      * An array of textual month names.
      * Override these values for international dates.
      * Example:
      * An array of textual month names.
      * Override these values for international dates.
      * Example:
@@ -365,8 +369,6 @@ Ext.Date.monthNames = [
     ...
 ];
 </code></pre>
     ...
 ];
 </code></pre>
-     * @type Array
-     * @static
      */
     monthNames : [
         "January",
      */
     monthNames : [
         "January",
@@ -384,6 +386,7 @@ Ext.Date.monthNames = [
     ],
 
     /**
     ],
 
     /**
+     * @property {Object} monthNumbers
      * 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:
      * 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:
@@ -394,8 +397,6 @@ Ext.Date.monthNumbers = {
     ...
 };
 </code></pre>
     ...
 };
 </code></pre>
-     * @type Object
-     * @static
      */
     monthNumbers : {
         Jan:0,
      */
     monthNumbers : {
         Jan:0,
@@ -412,12 +413,10 @@ Ext.Date.monthNumbers = {
         Dec:11
     },
     /**
         Dec:11
     },
     /**
-     * <p>The date format string that the {@link #dateRenderer} and {@link #date} functions use.
-     * see {@link #Date} for details.</p>
-     * <p>This defaults to <code>m/d/Y</code>, but may be overridden in a locale file.</p>
-     * @property defaultFormat
-     * @static
-     * @type String
+     * @property {String} defaultFormat
+     * <p>The date format string that the {@link Ext.util.Format#dateRenderer}
+     * and {@link Ext.util.Format#date} functions use.  See {@link Ext.Date} for details.</p>
+     * <p>This may be overridden in a locale file.</p>
      */
     defaultFormat : "m/d/Y",
     /**
      */
     defaultFormat : "m/d/Y",
     /**
@@ -425,7 +424,6 @@ Ext.Date.monthNumbers = {
      * Override this function for international dates.
      * @param {Number} month A zero-based javascript month number.
      * @return {String} The short month name.
      * Override this function for international dates.
      * @param {Number} month A zero-based javascript month number.
      * @return {String} The short month name.
-     * @static
      */
     getShortMonthName : function(month) {
         return utilDate.monthNames[month].substring(0, 3);
      */
     getShortMonthName : function(month) {
         return utilDate.monthNames[month].substring(0, 3);
@@ -436,7 +434,6 @@ Ext.Date.monthNumbers = {
      * Override this function for international dates.
      * @param {Number} day A zero-based javascript day number.
      * @return {String} The short day name.
      * Override this function for international dates.
      * @param {Number} day A zero-based javascript day number.
      * @return {String} The short day name.
-     * @static
      */
     getShortDayName : function(day) {
         return utilDate.dayNames[day].substring(0, 3);
      */
     getShortDayName : function(day) {
         return utilDate.dayNames[day].substring(0, 3);
@@ -447,7 +444,6 @@ Ext.Date.monthNumbers = {
      * Override this function for international dates.
      * @param {String} name The short/full month name.
      * @return {Number} The zero-based javascript month number.
      * Override this function for international dates.
      * @param {String} name The short/full month name.
      * @return {Number} The zero-based javascript month number.
-     * @static
      */
     getMonthNumber : function(name) {
         // handle camel casing for english month names (since the keys for the Ext.Date.monthNumbers hash are case sensitive)
      */
     getMonthNumber : function(name) {
         // handle camel casing for english month names (since the keys for the Ext.Date.monthNumbers hash are case sensitive)
@@ -458,7 +454,7 @@ Ext.Date.monthNumbers = {
      * Checks if the specified format contains hour information
      * @param {String} format The format to check
      * @return {Boolean} True if the format contains hour information
      * Checks if the specified format contains hour information
      * @param {String} format The format to check
      * @return {Boolean} True if the format contains hour information
-     * @static
+     * @method
      */
     formatContainsHourInfo : (function(){
         var stripEscapeRe = /(\\.)/g,
      */
     formatContainsHourInfo : (function(){
         var stripEscapeRe = /(\\.)/g,
@@ -474,7 +470,7 @@ Ext.Date.monthNumbers = {
      * @param {String} format The format to check
      * @return {Boolean} True if the format contains information about
      * date/day information.
      * @param {String} format The format to check
      * @return {Boolean} True if the format contains information about
      * date/day information.
-     * @static
+     * @method
      */
     formatContainsDateInfo : (function(){
         var stripEscapeRe = /(\\.)/g,
      */
     formatContainsDateInfo : (function(){
         var stripEscapeRe = /(\\.)/g,
@@ -498,7 +494,6 @@ 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
 </code></pre>
      * @type Object
 console.log(Ext.Date.format(new Date(), 'X'); // returns the current day of the month
 </code></pre>
      * @type Object
-     * @static
      */
     formatCodes : {
         d: "Ext.String.leftPad(this.getDate(), 2, '0')",
      */
     formatCodes : {
         d: "Ext.String.leftPad(this.getDate(), 2, '0')",
@@ -568,7 +563,6 @@ console.log(Ext.Date.format(new Date(), 'X'); // returns the current day of the
      * @param {Number} second (optional) Second
      * @param {Number} millisecond (optional) Millisecond
      * @return {Boolean} true if the passed parameters do not cause a Date "rollover", false otherwise.
      * @param {Number} second (optional) Second
      * @param {Number} millisecond (optional) Millisecond
      * @return {Boolean} true if the passed parameters do not cause a Date "rollover", false otherwise.
-     * @static
      */
     isValid : function(y, m, d, h, i, s, ms) {
         // setup defaults
      */
     isValid : function(y, m, d, h, i, s, ms) {
         // setup defaults
@@ -618,7 +612,6 @@ dt = Ext.Date.parse("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
      * @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date "rollover")
                         (defaults to false). Invalid date strings will return null when parsed.
      * @return {Date} The parsed Date.
      * @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date "rollover")
                         (defaults to false). Invalid date strings will return null when parsed.
      * @return {Date} The parsed Date.
-     * @static
      */
     parse : function(input, format, strict) {
         var p = utilDate.parseFunctions;
      */
     parse : function(input, format, strict) {
         var p = utilDate.parseFunctions;
@@ -865,7 +858,7 @@ dt = Ext.Date.parse("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
                 + "y = ty > Ext.Date.y2kYear ? 1900 + ty : 2000 + ty;\n", // 2-digit year
             s:"(\\d{1,2})"
         },
                 + "y = ty > Ext.Date.y2kYear ? 1900 + ty : 2000 + ty;\n", // 2-digit year
             s:"(\\d{1,2})"
         },
-        /**
+        /*
          * In the am/pm parsing routines, we allow both upper and lower case
          * even though it doesn't exactly match the spec. It gives much more flexibility
          * in being able to specify case insensitive regexes.
          * In the am/pm parsing routines, we allow both upper and lower case
          * even though it doesn't exactly match the spec. It gives much more flexibility
          * in being able to specify case insensitive regexes.
@@ -1085,6 +1078,7 @@ dt = Ext.Date.parse("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
      * (equivalent to the format specifier 'W', but without a leading zero).
      * @param {Date} date The date
      * @return {Number} 1 to 53
      * (equivalent to the format specifier 'W', but without a leading zero).
      * @param {Date} date The date
      * @return {Number} 1 to 53
+     * @method
      */
     getWeekOfYear : (function() {
         // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm
      */
     getWeekOfYear : (function() {
         // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm
@@ -1168,6 +1162,7 @@ console.log(Ext.Date.dayNames[lastDay]); //output: 'Wednesday'
      * Get the number of days in the current month, adjusted for leap year.
      * @param {Date} date The date
      * @return {Number} The number of days in the month.
      * Get the number of days in the current month, adjusted for leap year.
      * @param {Date} date The date
      * @return {Number} The number of days in the month.
+     * @method
      */
     getDaysInMonth: (function() {
         var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
      */
     getDaysInMonth: (function() {
         var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -1371,3 +1366,4 @@ console.log(dt2); //returns 'Tue Sep 26 2006 00:00:00'
 var utilDate = Ext.Date;
 
 })();
 var utilDate = Ext.Date;
 
 })();
+