X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/f5240829880f87e0cf581c6a296e436fdef0ef80..0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6:/src/util/Date.js diff --git a/src/util/Date.js b/src/util/Date.js index 010be519..44eaa3a5 100644 --- a/src/util/Date.js +++ b/src/util/Date.js @@ -1,8 +1,8 @@ /*! - * Ext JS Library 3.3.0 - * Copyright(c) 2006-2010 Ext JS, Inc. - * licensing@extjs.com - * http://www.extjs.com/license + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license */ /** * @class Date @@ -665,9 +665,12 @@ dt = Date.parseDate("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null calc = [], regex = [], special = false, - ch = ""; + ch = "", + i = 0, + obj, + last; - for (var i = 0; i < format.length; ++i) { + for (; i < format.length; ++i) { ch = format.charAt(i); if (!special && ch == "\\") { special = true; @@ -675,14 +678,22 @@ dt = Date.parseDate("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null special = false; regex.push(String.escape(ch)); } else { - var obj = $f(ch, currentGroup); + obj = $f(ch, currentGroup); currentGroup += obj.g; regex.push(obj.s); if (obj.g && obj.c) { - calc.push(obj.c); + if (obj.calcLast) { + last = obj.c; + } else { + calc.push(obj.c); + } } } } + + if (last) { + calc.push(last); + } Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i'); Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join(''))); @@ -799,14 +810,12 @@ dt = Date.parseDate("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null * even though it doesn't exactly match the spec. It gives much more flexibility * in being able to specify case insensitive regexes. */ - a: { - g:1, - c:"if (/(am)/i.test(results[{0}])) {\n" - + "if (!h || h == 12) { h = 0; }\n" - + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}", - s:"(am|pm|AM|PM)" + a: function(){ + return $f("A"); }, A: { + // We need to calculate the hour before we apply AM/PM when parsing + calcLast: true, g:1, c:"if (/(am)/i.test(results[{0}])) {\n" + "if (!h || h == 12) { h = 0; }\n"