Mootools/more : Added date format parameter to Date::Parse() method (propose on github https://github.com/mootools/mootools-more/pull/255)

This commit is contained in:
Benjamin Renard 2011-06-27 12:05:10 +02:00
parent 0c404082fd
commit de2336f68e

View file

@ -1174,7 +1174,7 @@ Date.extend({
return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
},
parse: function(from){
parse: function(from,format){
var t = typeOf(from);
if (t == 'number') return new Date(from);
if (t != 'string') return from;
@ -1182,7 +1182,7 @@ Date.extend({
if (!from.length) return null;
var parsed;
parsePatterns.some(function(pattern){
((format) ? [build(format)] : parsePatterns).some(function(pattern){
var bits = pattern.re.exec(from);
return (bits) ? (parsed = pattern.handler(bits)) : false;
});