Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / source / util / Date.js
diff --git a/source/util/Date.js b/source/util/Date.js
deleted file mode 100644 (file)
index 49f3a83..0000000
+++ /dev/null
@@ -1,1063 +0,0 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Date\r
- *\r
- * The date parsing and format syntax is a subset of\r
- * <a href="http://www.php.net/date">PHP's date() function</a>, and the formats that are\r
- * supported will provide results equivalent to their PHP versions.\r
- *\r
- * The following is a list of all currently supported formats:\r
- *<pre>\r
-Format  Description                                                               Example returned values\r
-------  -----------------------------------------------------------------------   -----------------------\r
-  d     Day of the month, 2 digits with leading zeros                             01 to 31\r
-  D     A short textual representation of the day of the week                     Mon to Sun\r
-  j     Day of the month without leading zeros                                    1 to 31\r
-  l     A full textual representation of the day of the week                      Sunday to Saturday\r
-  N     ISO-8601 numeric representation of the day of the week                    1 (for Monday) through 7 (for Sunday)\r
-  S     English ordinal suffix for the day of the month, 2 characters             st, nd, rd or th. Works well with j\r
-  w     Numeric representation of the day of the week                             0 (for Sunday) to 6 (for Saturday)\r
-  z     The day of the year (starting from 0)                                     0 to 364 (365 in leap years)\r
-  W     ISO-8601 week number of year, weeks starting on Monday                    01 to 53\r
-  F     A full textual representation of a month, such as January or March        January to December\r
-  m     Numeric representation of a month, with leading zeros                     01 to 12\r
-  M     A short textual representation of a month                                 Jan to Dec\r
-  n     Numeric representation of a month, without leading zeros                  1 to 12\r
-  t     Number of days in the given month                                         28 to 31\r
-  L     Whether it's a leap year                                                  1 if it is a leap year, 0 otherwise.\r
-  o     ISO-8601 year number (identical to (Y), but if the ISO week number (W)    Examples: 1998 or 2004\r
-        belongs to the previous or next year, that year is used instead)\r
-  Y     A full numeric representation of a year, 4 digits                         Examples: 1999 or 2003\r
-  y     A two digit representation of a year                                      Examples: 99 or 03\r
-  a     Lowercase Ante meridiem and Post meridiem                                 am or pm\r
-  A     Uppercase Ante meridiem and Post meridiem                                 AM or PM\r
-  g     12-hour format of an hour without leading zeros                           1 to 12\r
-  G     24-hour format of an hour without leading zeros                           0 to 23\r
-  h     12-hour format of an hour with leading zeros                              01 to 12\r
-  H     24-hour format of an hour with leading zeros                              00 to 23\r
-  i     Minutes, with leading zeros                                               00 to 59\r
-  s     Seconds, with leading zeros                                               00 to 59\r
-  u     Decimal fraction of a second                                              Examples:\r
-        (minimum 1 digit, arbitrary number of digits allowed)                     001 (i.e. 0.001s) or\r
-                                                                                  100 (i.e. 0.100s) or\r
-                                                                                  999 (i.e. 0.999s) or\r
-                                                                                  999876543210 (i.e. 0.999876543210s)\r
-  O     Difference to Greenwich time (GMT) in hours and minutes                   Example: +1030\r
-  P     Difference to Greenwich time (GMT) with colon between hours and minutes   Example: -08:00\r
-  T     Timezone abbreviation of the machine running the code                     Examples: EST, MDT, PDT ...\r
-  Z     Timezone offset in seconds (negative if west of UTC, positive if east)    -43200 to 50400\r
-  c     ISO 8601 date (note: the decimal fraction of a second, if specified,      Examples:\r
-        must contain at least 1 digit. There is no limit on the maximum number    2007-04-17T15:19:21+08:00 or\r
-        of digits allowed. see http://www.w3.org/TR/NOTE-datetime for more info)  2008-03-16T16:18:22Z or\r
-                                                                                  2009-02-15T17:17:23.9+01:00 or\r
-                                                                                  2010-01-14T18:16:24,999876543-07:00\r
-  U     Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)                1193432466 or -2138434463\r
-</pre>\r
- *\r
- * Example usage (note that you must escape format specifiers with '\\' to render them as character literals):\r
- * <pre><code>\r
-// Sample date:\r
-// 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'\r
-\r
-var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');\r
-document.write(dt.format('Y-m-d'));                           // 2007-01-10\r
-document.write(dt.format('F j, Y, g:i a'));                   // January 10, 2007, 3:05 pm\r
-document.write(dt.format('l, \\t\\he jS \\of F Y h:i:s A'));  // Wednesday, the 10th of January 2007 03:05:01 PM\r
- </code></pre>\r
- *\r
- * Here are some standard date/time patterns that you might find helpful.  They\r
- * are not part of the source of Date.js, but to use them you can simply copy this\r
- * block of code into any script that is included after Date.js and they will also become\r
- * globally available on the Date object.  Feel free to add or remove patterns as needed in your code.\r
- * <pre><code>\r
-Date.patterns = {\r
-    ISO8601Long:"Y-m-d H:i:s",\r
-    ISO8601Short:"Y-m-d",\r
-    ShortDate: "n/j/Y",\r
-    LongDate: "l, F d, Y",\r
-    FullDateTime: "l, F d, Y g:i:s A",\r
-    MonthDay: "F d",\r
-    ShortTime: "g:i A",\r
-    LongTime: "g:i:s A",\r
-    SortableDateTime: "Y-m-d\\TH:i:s",\r
-    UniversalSortableDateTime: "Y-m-d H:i:sO",\r
-    YearMonth: "F, Y"\r
-};\r
-</code></pre>\r
- *\r
- * Example usage:\r
- * <pre><code>\r
-var dt = new Date();\r
-document.write(dt.format(Date.patterns.ShortDate));\r
- </code></pre>\r
- */\r
-\r
-/*\r
- * Most of the date-formatting functions below are the excellent work of Baron Schwartz.\r
- * (see http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/)\r
- * They generate precompiled functions from format patterns instead of parsing and\r
- * processing each pattern every time a date is formatted. These functions are available\r
- * on every Date object.\r
- */\r
-\r
-(function() {\r
-\r
-// create private copy of Ext's String.format() method\r
-// - to remove unnecessary dependency\r
-// - to resolve namespace conflict with M$-Ajax's implementation\r
-function xf(format) {\r
-    var args = Array.prototype.slice.call(arguments, 1);\r
-    return format.replace(/\{(\d+)\}/g, function(m, i) {\r
-        return args[i];\r
-    });\r
-}\r
-\r
-\r
-// private\r
-Date.formatCodeToRegex = function(character, currentGroup) {\r
-    // Note: currentGroup - position in regex result array (see notes for Date.parseCodes below)\r
-    var p = Date.parseCodes[character];\r
-\r
-    if (p) {\r
-      p = Ext.type(p) == 'function'? p() : p;\r
-      Date.parseCodes[character] = p; // reassign function result to prevent repeated execution\r
-    }\r
-\r
-    return p? Ext.applyIf({\r
-      c: p.c? xf(p.c, currentGroup || "{0}") : p.c\r
-    }, p) : {\r
-        g:0,\r
-        c:null,\r
-        s:Ext.escapeRe(character) // treat unrecognised characters as literals\r
-    }\r
-}\r
-\r
-// private shorthand for Date.formatCodeToRegex since we'll be using it fairly often\r
-var $f = Date.formatCodeToRegex;\r
-\r
-Ext.apply(Date, {\r
-    // private\r
-    parseFunctions: {count:0},\r
-    parseRegexes: [],\r
-    formatFunctions: {count:0},\r
-    daysInMonth : [31,28,31,30,31,30,31,31,30,31,30,31],\r
-    y2kYear : 50,\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    MILLI : "ms",\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    SECOND : "s",\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    MINUTE : "mi",\r
-\r
-    /** Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    HOUR : "h",\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    DAY : "d",\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    MONTH : "mo",\r
-\r
-    /**\r
-     * Date interval constant\r
-     * @static\r
-     * @type String\r
-     */\r
-    YEAR : "y",\r
-\r
-    /**\r
-     * An array of textual day names.\r
-     * Override these values for international dates.\r
-     * Example:\r
-     *<pre><code>\r
-    Date.dayNames = [\r
-      'SundayInYourLang',\r
-      'MondayInYourLang',\r
-      ...\r
-    ];\r
-    </code></pre>\r
-     * @type Array\r
-     * @static\r
-     */\r
-    dayNames : [\r
-        "Sunday",\r
-        "Monday",\r
-        "Tuesday",\r
-        "Wednesday",\r
-        "Thursday",\r
-        "Friday",\r
-        "Saturday"\r
-    ],\r
-\r
-    /**\r
-     * An array of textual month names.\r
-     * Override these values for international dates.\r
-     * Example:\r
-     *<pre><code>\r
-    Date.monthNames = [\r
-      'JanInYourLang',\r
-      'FebInYourLang',\r
-      ...\r
-    ];\r
-    </code></pre>\r
-     * @type Array\r
-     * @static\r
-     */\r
-    monthNames : [\r
-        "January",\r
-        "February",\r
-        "March",\r
-        "April",\r
-        "May",\r
-        "June",\r
-        "July",\r
-        "August",\r
-        "September",\r
-        "October",\r
-        "November",\r
-        "December"\r
-    ],\r
-\r
-    /**\r
-     * An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive).\r
-     * Override these values for international dates.\r
-     * Example:\r
-     *<pre><code>\r
-    Date.monthNumbers = {\r
-      'ShortJanNameInYourLang':0,\r
-      'ShortFebNameInYourLang':1,\r
-      ...\r
-    };\r
-    </code></pre>\r
-     * @type Object\r
-     * @static\r
-     */\r
-    monthNumbers : {\r
-        Jan:0,\r
-        Feb:1,\r
-        Mar:2,\r
-        Apr:3,\r
-        May:4,\r
-        Jun:5,\r
-        Jul:6,\r
-        Aug:7,\r
-        Sep:8,\r
-        Oct:9,\r
-        Nov:10,\r
-        Dec:11\r
-    },\r
-\r
-    /**\r
-     * Get the short month name for the given month number.\r
-     * Override this function for international dates.\r
-     * @param {Number} month A zero-based javascript month number.\r
-     * @return {String} The short month name.\r
-     * @static\r
-     */\r
-    getShortMonthName : function(month) {\r
-        return Date.monthNames[month].substring(0, 3);\r
-    },\r
-\r
-    /**\r
-     * Get the short day name for the given day number.\r
-     * Override this function for international dates.\r
-     * @param {Number} day A zero-based javascript day number.\r
-     * @return {String} The short day name.\r
-     * @static\r
-     */\r
-    getShortDayName : function(day) {\r
-        return Date.dayNames[day].substring(0, 3);\r
-    },\r
-\r
-    /**\r
-     * Get the zero-based javascript month number for the given short/full month name.\r
-     * Override this function for international dates.\r
-     * @param {String} name The short/full month name.\r
-     * @return {Number} The zero-based javascript month number.\r
-     * @static\r
-     */\r
-    getMonthNumber : function(name) {\r
-        // handle camel casing for english month names (since the keys for the Date.monthNumbers hash are case sensitive)\r
-        return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];\r
-    },\r
-\r
-    /**\r
-     * The base format-code to formatting-function hashmap used by the {@link #format} method.\r
-     * Formatting functions are strings (or functions which return strings) which\r
-     * will return the appropriate value when evaluated in the context of the Date object\r
-     * from which the {@link #format} method is called.\r
-     * Add to / override these mappings for custom date formatting.\r
-     * Note: Date.format() treats characters as literals if an appropriate mapping cannot be found.\r
-     * Example:\r
-    <pre><code>\r
-    Date.formatCodes.x = "String.leftPad(this.getDate(), 2, '0')";\r
-    (new Date()).format("X"); // returns the current day of the month\r
-    </code></pre>\r
-     * @type Object\r
-     * @static\r
-     */\r
-    formatCodes : {\r
-        d: "String.leftPad(this.getDate(), 2, '0')",\r
-        D: "Date.getShortDayName(this.getDay())", // get localised short day name\r
-        j: "this.getDate()",\r
-        l: "Date.dayNames[this.getDay()]",\r
-        N: "(this.getDay() ? this.getDay() : 7)",\r
-        S: "this.getSuffix()",\r
-        w: "this.getDay()",\r
-        z: "this.getDayOfYear()",\r
-        W: "String.leftPad(this.getWeekOfYear(), 2, '0')",\r
-        F: "Date.monthNames[this.getMonth()]",\r
-        m: "String.leftPad(this.getMonth() + 1, 2, '0')",\r
-        M: "Date.getShortMonthName(this.getMonth())", // get localised short month name\r
-        n: "(this.getMonth() + 1)",\r
-        t: "this.getDaysInMonth()",\r
-        L: "(this.isLeapYear() ? 1 : 0)",\r
-        o: "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0)))",\r
-        Y: "this.getFullYear()",\r
-        y: "('' + this.getFullYear()).substring(2, 4)",\r
-        a: "(this.getHours() < 12 ? 'am' : 'pm')",\r
-        A: "(this.getHours() < 12 ? 'AM' : 'PM')",\r
-        g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",\r
-        G: "this.getHours()",\r
-        h: "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",\r
-        H: "String.leftPad(this.getHours(), 2, '0')",\r
-        i: "String.leftPad(this.getMinutes(), 2, '0')",\r
-        s: "String.leftPad(this.getSeconds(), 2, '0')",\r
-        u: "String.leftPad(this.getMilliseconds(), 3, '0')",\r
-        O: "this.getGMTOffset()",\r
-        P: "this.getGMTOffset(true)",\r
-        T: "this.getTimezone()",\r
-        Z: "(this.getTimezoneOffset() * -60)",\r
-        c: function() { // ISO-8601 -- GMT format\r
-            for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {\r
-                var e = c.charAt(i);\r
-                code.push(e == "T" ? "'T'" : Date.getFormatCode(e)); // treat T as a character literal\r
-            }\r
-            return code.join(" + ");\r
-        },\r
-        /*\r
-        c: function() { // ISO-8601 -- UTC format\r
-            return [\r
-              "this.getUTCFullYear()", "'-'",\r
-              "String.leftPad(this.getUTCMonth() + 1, 2, '0')", "'-'",\r
-              "String.leftPad(this.getUTCDate(), 2, '0')",\r
-              "'T'",\r
-              "String.leftPad(this.getUTCHours(), 2, '0')", "':'",\r
-              "String.leftPad(this.getUTCMinutes(), 2, '0')", "':'",\r
-              "String.leftPad(this.getUTCSeconds(), 2, '0')",\r
-              "'Z'"\r
-            ].join(" + ");\r
-        },\r
-        */\r
-        U: "Math.round(this.getTime() / 1000)"\r
-    },\r
-\r
-    /**\r
-     * Parses the passed string using the specified format. Note that this function expects dates in normal calendar\r
-     * format, meaning that months are 1-based (1 = January) and not zero-based like in JavaScript dates.  Any part of\r
-     * the date format that is not specified will default to the current date value for that part.  Time parts can also\r
-     * be specified, but default to 0.  Keep in mind that the input date string must precisely match the specified format\r
-     * string or the parse operation will fail.\r
-     * Example Usage:\r
-     *<pre><code>\r
-    //dt = Fri May 25 2007 (current date)\r
-    var dt = new Date();\r
-\r
-    //dt = Thu May 25 2006 (today's month/day in 2006)\r
-    dt = Date.parseDate("2006", "Y");\r
-\r
-    //dt = Sun Jan 15 2006 (all date parts specified)\r
-    dt = Date.parseDate("2006-01-15", "Y-m-d");\r
-\r
-    //dt = Sun Jan 15 2006 15:20:01 GMT-0600 (CST)\r
-    dt = Date.parseDate("2006-01-15 3:20:01 PM", "Y-m-d h:i:s A" );\r
-    </code></pre>\r
-     * @param {String} input The unparsed date as a string.\r
-     * @param {String} format The format the date is in.\r
-     * @return {Date} The parsed date.\r
-     * @static\r
-     */\r
-    parseDate : function(input, format) {\r
-        var p = Date.parseFunctions;\r
-        if (p[format] == null) {\r
-            Date.createParser(format);\r
-        }\r
-        var func = p[format];\r
-        return Date[func](input);\r
-    },\r
-\r
-    // private\r
-    getFormatCode : function(character) {\r
-        var f = Date.formatCodes[character];\r
-\r
-        if (f) {\r
-          f = Ext.type(f) == 'function'? f() : f;\r
-          Date.formatCodes[character] = f; // reassign function result to prevent repeated execution\r
-        }\r
-\r
-        // note: unknown characters are treated as literals\r
-        return f || ("'" + String.escape(character) + "'");\r
-    },\r
-\r
-    // private\r
-    createNewFormat : function(format) {\r
-        var funcName = "format" + Date.formatFunctions.count++,\r
-            code = "Date.prototype." + funcName + " = function(){return ",\r
-            special = false,\r
-            ch = '';\r
-\r
-        Date.formatFunctions[format] = funcName;\r
-\r
-        for (var i = 0; i < format.length; ++i) {\r
-            ch = format.charAt(i);\r
-            if (!special && ch == "\\") {\r
-                special = true;\r
-            }\r
-            else if (special) {\r
-                special = false;\r
-                code += "'" + String.escape(ch) + "' + ";\r
-            }\r
-            else {\r
-                code += Date.getFormatCode(ch) + " + ";\r
-            }\r
-        }\r
-        eval(code.substring(0, code.length - 3) + ";}");\r
-    },\r
-\r
-    // private\r
-    createParser : function() {\r
-        var code = [\r
-            "Date.{0} = function(input){",\r
-                "var y, m, d, h = 0, i = 0, s = 0, ms = 0, o, z, u, v;",\r
-                "input = String(input);",\r
-                "d = new Date();",\r
-                "y = d.getFullYear();",\r
-                "m = d.getMonth();",\r
-                "d = d.getDate();",\r
-                "var results = input.match(Date.parseRegexes[{1}]);",\r
-                "if(results && results.length > 0){",\r
-                    "{2}",\r
-                    "if(u){",\r
-                        "v = new Date(u * 1000);", // give top priority to UNIX time\r
-                    "}else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0 && ms >= 0){",\r
-                        "v = new Date(y, m, d, h, i, s, ms);",\r
-                    "}else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0){",\r
-                        "v = new Date(y, m, d, h, i, s);",\r
-                    "}else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0){",\r
-                        "v = new Date(y, m, d, h, i);",\r
-                    "}else if (y >= 0 && m >= 0 && d > 0 && h >= 0){",\r
-                        "v = new Date(y, m, d, h);",\r
-                    "}else if (y >= 0 && m >= 0 && d > 0){",\r
-                        "v = new Date(y, m, d);",\r
-                    "}else if (y >= 0 && m >= 0){",\r
-                        "v = new Date(y, m);",\r
-                    "}else if (y >= 0){",\r
-                        "v = new Date(y);",\r
-                    "}",\r
-                "}",\r
-                "return (v && (z != null || o != null))?" // favour UTC offset over GMT offset\r
-                    + " (Ext.type(z) == 'number' ? v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - z) :" // reset to UTC, then add offset\r
-                    + " v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn))) : v;", // reset to GMT, then add offset\r
-            "}"\r
-        ].join('\n');\r
-\r
-        return function(format) {\r
-            var funcName = "parse" + Date.parseFunctions.count++,\r
-                regexNum = Date.parseRegexes.length,\r
-                currentGroup = 1,\r
-                calc = "",\r
-                regex = "",\r
-                special = false,\r
-                ch = "";\r
-\r
-            Date.parseFunctions[format] = funcName;\r
-\r
-            for (var i = 0; i < format.length; ++i) {\r
-                ch = format.charAt(i);\r
-                if (!special && ch == "\\") {\r
-                    special = true;\r
-                }\r
-                else if (special) {\r
-                    special = false;\r
-                    regex += String.escape(ch);\r
-                }\r
-                else {\r
-                    var obj = $f(ch, currentGroup);\r
-                    currentGroup += obj.g;\r
-                    regex += obj.s;\r
-                    if (obj.g && obj.c) {\r
-                        calc += obj.c;\r
-                    }\r
-                }\r
-            }\r
-\r
-            Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$", "i");\r
-            eval(xf(code, funcName, regexNum, calc));\r
-        }\r
-    }(),\r
-\r
-    // private\r
-    parseCodes : {\r
-        /*\r
-         * Notes:\r
-         * g = {Number} calculation group (0 or 1. only group 1 contributes to date calculations.)\r
-         * c = {String} calculation method (required for group 1. null for group 0. {0} = currentGroup - position in regex result array)\r
-         * s = {String} regex pattern. all matches are stored in results[], and are accessible by the calculation mapped to 'c'\r
-         */\r
-        d: {\r
-            g:1,\r
-            c:"d = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{2})" // day of month with leading zeroes (01 - 31)\r
-        },\r
-        j: {\r
-            g:1,\r
-            c:"d = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{1,2})" // day of month without leading zeroes (1 - 31)\r
-        },\r
-        D: function() {\r
-            for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i); // get localised short day names\r
-            return {\r
-                g:0,\r
-                c:null,\r
-                s:"(?:" + a.join("|") +")"\r
-            }\r
-        },\r
-        l: function() {\r
-            return {\r
-                g:0,\r
-                c:null,\r
-                s:"(?:" + Date.dayNames.join("|") + ")"\r
-            }\r
-        },\r
-        N: {\r
-            g:0,\r
-            c:null,\r
-            s:"[1-7]" // ISO-8601 day number (1 (monday) - 7 (sunday))\r
-        },\r
-        S: {\r
-            g:0,\r
-            c:null,\r
-            s:"(?:st|nd|rd|th)"\r
-        },\r
-        w: {\r
-            g:0,\r
-            c:null,\r
-            s:"[0-6]" // javascript day number (0 (sunday) - 6 (saturday))\r
-        },\r
-        z: {\r
-            g:0,\r
-            c:null,\r
-            s:"(?:\\d{1,3})" // day of the year (0 - 364 (365 in leap years))\r
-        },\r
-        W: {\r
-            g:0,\r
-            c:null,\r
-            s:"(?:\\d{2})" // ISO-8601 week number (with leading zero)\r
-        },\r
-        F: function() {\r
-            return {\r
-                g:1,\r
-                c:"m = parseInt(Date.getMonthNumber(results[{0}]), 10);\n", // get localised month number\r
-                s:"(" + Date.monthNames.join("|") + ")"\r
-            }\r
-        },\r
-        M: function() {\r
-            for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i); // get localised short month names\r
-            return Ext.applyIf({\r
-                s:"(" + a.join("|") + ")"\r
-            }, $f("F"));\r
-        },\r
-        m: {\r
-            g:1,\r
-            c:"m = parseInt(results[{0}], 10) - 1;\n",\r
-            s:"(\\d{2})" // month number with leading zeros (01 - 12)\r
-        },\r
-        n: {\r
-            g:1,\r
-            c:"m = parseInt(results[{0}], 10) - 1;\n",\r
-            s:"(\\d{1,2})" // month number without leading zeros (1 - 12)\r
-        },\r
-        t: {\r
-            g:0,\r
-            c:null,\r
-            s:"(?:\\d{2})" // no. of days in the month (28 - 31)\r
-        },\r
-        L: {\r
-            g:0,\r
-            c:null,\r
-            s:"(?:1|0)"\r
-        },\r
-        o: function() {\r
-            return $f("Y");\r
-        },\r
-        Y: {\r
-            g:1,\r
-            c:"y = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{4})" // 4-digit year\r
-        },\r
-        y: {\r
-            g:1,\r
-            c:"var ty = parseInt(results[{0}], 10);\n"\r
-                + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n", // 2-digit year\r
-            s:"(\\d{1,2})"\r
-        },\r
-        a: {\r
-            g:1,\r
-            c:"if (results[{0}] == 'am') {\n"\r
-                + "if (h == 12) { h = 0; }\n"\r
-                + "} else { if (h < 12) { h += 12; }}",\r
-            s:"(am|pm)"\r
-        },\r
-        A: {\r
-            g:1,\r
-            c:"if (results[{0}] == 'AM') {\n"\r
-                + "if (h == 12) { h = 0; }\n"\r
-                + "} else { if (h < 12) { h += 12; }}",\r
-            s:"(AM|PM)"\r
-        },\r
-        g: function() {\r
-            return $f("G");\r
-        },\r
-        G: {\r
-            g:1,\r
-            c:"h = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{1,2})" // 24-hr format of an hour without leading zeroes (0 - 23)\r
-        },\r
-        h: function() {\r
-            return $f("H");\r
-        },\r
-        H: {\r
-            g:1,\r
-            c:"h = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{2})" //  24-hr format of an hour with leading zeroes (00 - 23)\r
-        },\r
-        i: {\r
-            g:1,\r
-            c:"i = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{2})" // minutes with leading zeros (00 - 59)\r
-        },\r
-        s: {\r
-            g:1,\r
-            c:"s = parseInt(results[{0}], 10);\n",\r
-            s:"(\\d{2})" // seconds with leading zeros (00 - 59)\r
-        },\r
-        u: {\r
-            g:1,\r
-            c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",\r
-            s:"(\\d+)" // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)\r
-        },\r
-        O: {\r
-            g:1,\r
-            c:[\r
-                "o = results[{0}];",\r
-                "var sn = o.substring(0,1);", // get + / - sign\r
-                "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);", // get hours (performs minutes-to-hour conversion also, just in case)\r
-                "var mn = o.substring(3,5) % 60;", // get minutes\r
-                "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n" // -12hrs <= GMT offset <= 14hrs\r
-            ].join("\n"),\r
-            s: "([+\-]\\d{4})" // GMT offset in hrs and mins\r
-        },\r
-        P: {\r
-            g:1,\r
-            c:[\r
-                "o = results[{0}];",\r
-                "var sn = o.substring(0,1);", // get + / - sign\r
-                "var hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60);", // get hours (performs minutes-to-hour conversion also, just in case)\r
-                "var mn = o.substring(4,6) % 60;", // get minutes\r
-                "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n" // -12hrs <= GMT offset <= 14hrs\r
-            ].join("\n"),\r
-            s: "([+\-]\\d{2}:\\d{2})" // GMT offset in hrs and mins (with colon separator)\r
-        },\r
-        T: {\r
-            g:0,\r
-            c:null,\r
-            s:"[A-Z]{1,4}" // timezone abbrev. may be between 1 - 4 chars\r
-        },\r
-        Z: {\r
-            g:1,\r
-            c:"z = results[{0}] * 1;\n" // -43200 <= UTC offset <= 50400\r
-                  + "z = (-43200 <= z && z <= 50400)? z : null;\n",\r
-            s:"([+\-]?\\d{1,5})" // leading '+' sign is optional for UTC offset\r
-        },\r
-        c: function() {\r
-            var calc = [],\r
-                arr = [\r
-                    $f("Y", 1), // year\r
-                    $f("m", 2), // month\r
-                    $f("d", 3), // day\r
-                    $f("h", 4), // hour\r
-                    $f("i", 5), // minute\r
-                    $f("s", 6), // second\r
-                    {c:"ms = (results[7] || '.0').substring(1); ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"}, // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)\r
-                    {c:[ // allow both "Z" (i.e. UTC) and "+08:00" (i.e. UTC offset) time zone delimiters\r
-                        "if(results[9] == 'Z'){",\r
-                            "z = 0;",\r
-                        "}else{",\r
-                            $f("P", 9).c,\r
-                        "}"\r
-                    ].join('\n')}\r
-                ];\r
-\r
-            for (var i = 0, l = arr.length; i < l; ++i) {\r
-                calc.push(arr[i].c);\r
-            }\r
-\r
-            return {\r
-                g:1,\r
-                c:calc.join(""),\r
-                s:arr[0].s + "-" + arr[1].s + "-" + arr[2].s + "T" + arr[3].s + ":" + arr[4].s + ":" + arr[5].s\r
-                      + "((\.|,)\\d+)?" // decimal fraction of a second (e.g. ",998465" or ".998465")\r
-                      + "(Z|([+\-]\\d{2}:\\d{2}))" // "Z" (UTC) or "+08:00" (UTC offset)\r
-            }\r
-        },\r
-        U: {\r
-            g:1,\r
-            c:"u = parseInt(results[{0}], 10);\n",\r
-            s:"(-?\\d+)" // leading minus sign indicates seconds before UNIX epoch\r
-        }\r
-    }\r
-});\r
-\r
-}());\r
-\r
-Ext.apply(Date.prototype, {\r
-    // private\r
-    dateFormat : function(format) {\r
-        if (Date.formatFunctions[format] == null) {\r
-            Date.createNewFormat(format);\r
-        }\r
-        var func = Date.formatFunctions[format];\r
-        return this[func]();\r
-    },\r
-\r
-    /**\r
-     * Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').\r
-     *\r
-     * Note: The date string returned by the javascript Date object's toString() method varies\r
-     * between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America).\r
-     * For a given date string e.g. "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)",\r
-     * getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses\r
-     * (which may or may not be present), failing which it proceeds to get the timezone abbreviation\r
-     * from the GMT offset portion of the date string.\r
-     * @return {String} The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).\r
-     */\r
-    getTimezone : function() {\r
-        // the following list shows the differences between date strings from different browsers on a WinXP SP2 machine from an Asian locale:\r
-        //\r
-        // Opera  : "Thu, 25 Oct 2007 22:53:45 GMT+0800" -- shortest (weirdest) date string of the lot\r
-        // Safari : "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)" -- value in parentheses always gives the correct timezone (same as FF)\r
-        // FF     : "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)" -- value in parentheses always gives the correct timezone\r
-        // IE     : "Thu Oct 25 22:54:35 UTC+0800 2007" -- (Asian system setting) look for 3-4 letter timezone abbrev\r
-        // IE     : "Thu Oct 25 17:06:37 PDT 2007" -- (American system setting) look for 3-4 letter timezone abbrev\r
-        //\r
-        // this crazy regex attempts to guess the correct timezone abbreviation despite these differences.\r
-        // step 1: (?:\((.*)\) -- find timezone in parentheses\r
-        // step 2: ([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?) -- if nothing was found in step 1, find timezone from timezone offset portion of date string\r
-        // step 3: remove all non uppercase characters found in step 1 and 2\r
-        return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");\r
-    },\r
-\r
-    /**\r
-     * Get the offset from GMT of the current date (equivalent to the format specifier 'O').\r
-     * @param {Boolean} colon true to separate the hours and minutes with a colon (defaults to false).\r
-     * @return {String} The 4-character offset string prefixed with + or - (e.g. '-0600').\r
-     */\r
-    getGMTOffset : function(colon) {\r
-        return (this.getTimezoneOffset() > 0 ? "-" : "+")\r
-            + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0")\r
-            + (colon ? ":" : "")\r
-            + String.leftPad(Math.abs(this.getTimezoneOffset() % 60), 2, "0");\r
-    },\r
-\r
-    /**\r
-     * Get the numeric day number of the year, adjusted for leap year.\r
-     * @return {Number} 0 to 364 (365 in leap years).\r
-     */\r
-    getDayOfYear : function() {\r
-        var num = 0;\r
-        Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;\r
-        for (var i = 0; i < this.getMonth(); ++i) {\r
-            num += Date.daysInMonth[i];\r
-        }\r
-        return num + this.getDate() - 1;\r
-    },\r
-\r
-    /**\r
-     * Get the numeric ISO-8601 week number of the year.\r
-     * (equivalent to the format specifier 'W', but without a leading zero).\r
-     * @return {Number} 1 to 53\r
-     */\r
-    getWeekOfYear : function() {\r
-        // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm\r
-        var ms1d = 864e5, // milliseconds in a day\r
-            ms7d = 7 * ms1d; // milliseconds in a week\r
-\r
-        return function() { // return a closure so constants get calculated only once\r
-            var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d, // an Absolute Day Number\r
-                AWN = Math.floor(DC3 / 7), // an Absolute Week Number\r
-                Wyr = new Date(AWN * ms7d).getUTCFullYear();\r
-\r
-            return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;\r
-        }\r
-    }(),\r
-\r
-    /**\r
-     * Whether or not the current date is in a leap year.\r
-     * @return {Boolean} True if the current date is in a leap year, else false.\r
-     */\r
-    isLeapYear : function() {\r
-        var year = this.getFullYear();\r
-        return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));\r
-    },\r
-\r
-    /**\r
-     * Get the first day of the current month, adjusted for leap year.  The returned value\r
-     * is the numeric day index within the week (0-6) which can be used in conjunction with\r
-     * the {@link #monthNames} array to retrieve the textual day name.\r
-     * Example:\r
-     *<pre><code>\r
-    var dt = new Date('1/10/2007');\r
-    document.write(Date.dayNames[dt.getFirstDayOfMonth()]); //output: 'Monday'\r
-    </code></pre>\r
-     * @return {Number} The day number (0-6).\r
-     */\r
-    getFirstDayOfMonth : function() {\r
-        var day = (this.getDay() - (this.getDate() - 1)) % 7;\r
-        return (day < 0) ? (day + 7) : day;\r
-    },\r
-\r
-    /**\r
-     * Get the last day of the current month, adjusted for leap year.  The returned value\r
-     * is the numeric day index within the week (0-6) which can be used in conjunction with\r
-     * the {@link #monthNames} array to retrieve the textual day name.\r
-     * Example:\r
-     *<pre><code>\r
-    var dt = new Date('1/10/2007');\r
-    document.write(Date.dayNames[dt.getLastDayOfMonth()]); //output: 'Wednesday'\r
-    </code></pre>\r
-     * @return {Number} The day number (0-6).\r
-     */\r
-    getLastDayOfMonth : function() {\r
-        var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;\r
-        return (day < 0) ? (day + 7) : day;\r
-    },\r
-\r
-\r
-    /**\r
-     * Get the date of the first day of the month in which this date resides.\r
-     * @return {Date}\r
-     */\r
-    getFirstDateOfMonth : function() {\r
-        return new Date(this.getFullYear(), this.getMonth(), 1);\r
-    },\r
-\r
-    /**\r
-     * Get the date of the last day of the month in which this date resides.\r
-     * @return {Date}\r
-     */\r
-    getLastDateOfMonth : function() {\r
-        return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());\r
-    },\r
-\r
-    /**\r
-     * Get the number of days in the current month, adjusted for leap year.\r
-     * @return {Number} The number of days in the month.\r
-     */\r
-    getDaysInMonth : function() {\r
-        Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;\r
-        return Date.daysInMonth[this.getMonth()];\r
-    },\r
-\r
-    /**\r
-     * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').\r
-     * @return {String} 'st, 'nd', 'rd' or 'th'.\r
-     */\r
-    getSuffix : function() {\r
-        switch (this.getDate()) {\r
-            case 1:\r
-            case 21:\r
-            case 31:\r
-                return "st";\r
-            case 2:\r
-            case 22:\r
-                return "nd";\r
-            case 3:\r
-            case 23:\r
-                return "rd";\r
-            default:\r
-                return "th";\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Creates and returns a new Date instance with the exact same date value as the called instance.\r
-     * Dates are copied and passed by reference, so if a copied date variable is modified later, the original\r
-     * variable will also be changed.  When the intention is to create a new variable that will not\r
-     * modify the original instance, you should create a clone.\r
-     *\r
-     * Example of correctly cloning a date:\r
-     * <pre><code>\r
-    //wrong way:\r
-    var orig = new Date('10/1/2006');\r
-    var copy = orig;\r
-    copy.setDate(5);\r
-    document.write(orig);  //returns 'Thu Oct 05 2006'!\r
-\r
-    //correct way:\r
-    var orig = new Date('10/1/2006');\r
-    var copy = orig.clone();\r
-    copy.setDate(5);\r
-    document.write(orig);  //returns 'Thu Oct 01 2006'\r
-    </code></pre>\r
-     * @return {Date} The new Date instance.\r
-     */\r
-    clone : function() {\r
-        return new Date(this.getTime());\r
-    },\r
-\r
-    /**\r
-     * Clears any time information from this date.\r
-     @param {Boolean} clone true to create a clone of this date, clear the time and return it (defaults to false).\r
-     @return {Date} this or the clone.\r
-     */\r
-    clearTime : function(clone){\r
-        if(clone){\r
-            return this.clone().clearTime();\r
-        }\r
-        this.setHours(0);\r
-        this.setMinutes(0);\r
-        this.setSeconds(0);\r
-        this.setMilliseconds(0);\r
-        return this;\r
-    },\r
-\r
-    /**\r
-     * Provides a convenient method of performing basic date arithmetic.  This method\r
-     * does not modify the Date instance being called - it creates and returns\r
-     * a new Date instance containing the resulting date value.\r
-     *\r
-     * Examples:\r
-     * <pre><code>\r
-    //Basic usage:\r
-    var dt = new Date('10/29/2006').add(Date.DAY, 5);\r
-    document.write(dt); //returns 'Fri Oct 06 2006 00:00:00'\r
-\r
-    //Negative values will subtract correctly:\r
-    var dt2 = new Date('10/1/2006').add(Date.DAY, -5);\r
-    document.write(dt2); //returns 'Tue Sep 26 2006 00:00:00'\r
-\r
-    //You can even chain several calls together in one line!\r
-    var dt3 = new Date('10/1/2006').add(Date.DAY, 5).add(Date.HOUR, 8).add(Date.MINUTE, -30);\r
-    document.write(dt3); //returns 'Fri Oct 06 2006 07:30:00'\r
-     </code></pre>\r
-     *\r
-     * @param {String} interval   A valid date interval enum value.\r
-     * @param {Number} value      The amount to add to the current date.\r
-     * @return {Date} The new Date instance.\r
-     */\r
-    add : function(interval, value){\r
-        var d = this.clone();\r
-        if (!interval || value === 0) return d;\r
-\r
-        switch(interval.toLowerCase()){\r
-            case Date.MILLI:\r
-                d.setMilliseconds(this.getMilliseconds() + value);\r
-                break;\r
-            case Date.SECOND:\r
-                d.setSeconds(this.getSeconds() + value);\r
-                break;\r
-            case Date.MINUTE:\r
-                d.setMinutes(this.getMinutes() + value);\r
-                break;\r
-            case Date.HOUR:\r
-                d.setHours(this.getHours() + value);\r
-                break;\r
-            case Date.DAY:\r
-                d.setDate(this.getDate() + value);\r
-                break;\r
-            case Date.MONTH:\r
-                var day = this.getDate();\r
-                if(day > 28){\r
-                    day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());\r
-                }\r
-                d.setDate(day);\r
-                d.setMonth(this.getMonth() + value);\r
-                break;\r
-            case Date.YEAR:\r
-                d.setFullYear(this.getFullYear() + value);\r
-                break;\r
-        }\r
-        return d;\r
-    },\r
-\r
-    /**\r
-     * Checks if this date falls on or between the given start and end dates.\r
-     * @param {Date} start Start date\r
-     * @param {Date} end End date\r
-     * @return {Boolean} true if this date falls on or between the given start and end dates.\r
-     */\r
-    between : function(start, end){\r
-        var t = this.getTime();\r
-        return start.getTime() <= t && t <= end.getTime();\r
-    }\r
-});\r
-\r
-\r
-/**\r
- * Formats a date given the supplied format string.\r
- * @param {String} format The format string.\r
- * @return {String} The formatted date.\r
- * @method format\r
- */\r
-Date.prototype.format = Date.prototype.dateFormat;\r
-\r
-\r
-// private\r
-// safari setMonth is broken\r
-if(Ext.isSafari){\r
-    Date.brokenSetMonth = Date.prototype.setMonth;\r
-    Date.prototype.setMonth = function(num){\r
-        if(num <= -1){\r
-            var n = Math.ceil(-num);\r
-            var back_year = Math.ceil(n/12);\r
-            var month = (n % 12) ? 12 - n % 12 : 0 ;\r
-            this.setFullYear(this.getFullYear() - back_year);\r
-            return Date.brokenSetMonth.call(this, month);\r
-        } else {\r
-            return Date.brokenSetMonth.apply(this, arguments);\r
-        }\r
-    };\r
-}
\ No newline at end of file