Mootools/more : Added date format parameter to Date::Parse() method (propose on githu...
authorBenjamin Renard <brenard@easter-eggs.com>
Mon, 27 Jun 2011 10:05:10 +0000 (12:05 +0200)
committerBenjamin Renard <brenard@easter-eggs.com>
Mon, 27 Jun 2011 10:05:10 +0000 (12:05 +0200)
public_html/includes/js/mootools-more.js

index d5f9dd1..fff646d 100644 (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;
                });