format keys not supported by Date.defineParser(): %e, %l #1154

Open
scags9876 opened this Issue Oct 11, 2012 · 1 comment

Projects

None yet

1 participant

@scags9876

Docs state that:
All of the same keys that are supported in Date:format are supported [in the pattern passed to Date.defineParser(pattern)].

This is not true. The following do not result in a valid parse string:

e - the date as one digit (1, 5, 12, etc)
l - the hour (12-hour clock) as a digit (range 1 to 12). Single digits are preceded by a blank space.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@scags9876

patch for this issue: (sorry about the text patch, issues with my git right now)

@@ -1229,7 +1229,9 @@
        z: /Z|[+-]\d{2}(?::?\d{2})?/
 };

+keys.e = keys.d;
 keys.m = keys.I;
+keys.l = keys.I;
 keys.S = keys.M;

 var currentLanguage;
@@ -1274,7 +1276,7 @@
                                year = bits.y || bits.Y;

                        if (year != null) handle.call(date, 'y', year); // need to start in the right year
-                       if ('d' in bits) handle.call(date, 'd', 1);
+                       if ('d' in bits || 'e' in bits) handle.call(date, 'd', 1);
                        if ('m' in bits || bits.b || bits.B) handle.call(date, 'm', 1);

                        for (var key in bits) handle.call(date, key, bits[key]);
@@ -1289,8 +1291,8 @@
        switch (key){
                case 'a': case 'A': return this.set('day', Date.parseDay(value, true));
                case 'b': case 'B': return this.set('mo', Date.parseMonth(value, true));
-               case 'd': return this.set('date', value);
-               case 'H': case 'I': return this.set('hr', value);
+               case 'd': case 'e': return this.set('date', value);
+               case 'H': case 'I': case 'l': return this.set('hr', value);
                case 'm': return this.set('mo', value - 1);
                case 'M': return this.set('min', value);
                case 'p': return this.set('ampm', value.replace(/\./g, ''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment