View Full Version : [FIXED-715][3.x/2.x]Date.createParser() should not create case-insensitive parseRegex

11 Mar 2010, 10:20 AM
running the following code in the 3.x / 2.x codebase

Date.parseDate('8:00 aM', 'g:i A'); // gives 8pm of the current day

which is incorrect.

it should return null instead because the date string to be parsed does not match the specified parse format.

this is due to a bug in the RegExp() object created by the Date#createParser() method:

Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", "i");

simply removing the case-insensitive "i" flag resolves the issue.
see 445868 for a discussion of the problem.

the TimeField altFormats config also needs to be updated to avoid the bug reported by @JAnderson in the referenced thread, where the time string "800AM" is converted to "8:00 PM" by the TimeField:

Ext.override(Ext.form.TimeField, {
altFormats: Ext.form.TimeField.prototype.altFormats + '|gi a|hi a|giA|hiA|gi A|hi A'

12 Mar 2010, 12:28 AM
fixed by @jamie in
rev 6279:

[type]: change
[module]: TimeField
[id]: #715
[desc]: Refs #715. Updated altFormats defaults.

and rev 6280:

[type]: fix
[module]: Date
[id]: #715
[desc]: Fixes #715. Date parser is no longer flags for a case insensitive regex.