-
28 Oct 2008 10:45 PM #1
[2.2][CLOSED] Date.parseDate causes js error in IE7, when 'A' symbol is used
[2.2][CLOSED] Date.parseDate causes js error in IE7, when 'A' symbol is used
Causes js error in IE7.Code:var dt=Date.parseDate('10/20/2008 10:10:00 AM','m/d/Y h:i:s A');
Works fine.Code:var dt=Date.parseDate('10/20/2008 10:10:00','m/d/Y h:i:s');
In ext 2.0.2 this function works correctly.
-
28 Oct 2008 10:57 PM #2
i just tried this in FF3/IE6 using stock 2.2:
and it works as expected.Code:Ext.onReady(function() { if (window.console) { console.log('Date.parseDate("10/20/2008 10:10:00 AM", "m/d/Y h:i:s A") = %o', Date.parseDate("10/20/2008 10:10:00 AM", "m/d/Y h:i:s A")); } else { alert(Date.parseDate("10/20/2008 10:10:00 AM", "m/d/Y h:i:s A")); } });
don't have IE7 with me atm, but i don't see any reason why it should behave differently in IE7.
can anyone else confirm this behaviour?
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
28 Oct 2008 11:16 PM #3
Fine for me, IE7.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
28 Oct 2008 11:40 PM #4
Resolved
Resolved
Problem resolved, this was not actually ext-2.2 bug, but ext-basex 2.3 adapter bug, which does not have proper String.format function.
-
29 Oct 2008 3:25 AM #5
Some details, maybe this could be usefull for others.
Originally problem was that DateField and TimeField does not render datetime passed as 'm/d/Y h:i
A' format. When I try to resolve this issue, I found, that this control uses Date.parseDate for parsing date and time, and parseDate internally uses String.format function, which breaks js execution.
When I ran into this, I found, that ExtJS calls MS Ajax String.format (I use ASP.NET with AJAX extensions) instead of ExtJS String.format function. But, as I thought String.format should work similar in MS Ajax and ExtJS.
In ext-all-debug.js I found, that format string does not escaped '{' and '}' with '{{' and '}}' as should. I changed parseCodes and made a little patch, which allows me to uses Ext-2.2 simultaneously with MS Ajax.
So the bug is actually in extjs could be divided into two subbugs:
1. ExtJS should be able to escape '{' and '}' in String.format function
2. ExtJs should not call ms ajax functions.
patch (use this only if you are using MS Ajax): add this code after loading extjs scripts,
Code:Ext.apply(Date.parseCodes, { A: { g:1, c:"if (results[{0}] == 'AM') {{\n" + "if (h == 12) {{ h = 0; }}\n" + "}} else {{ if (h < 12) {{ h += 12; }}}}", s:"(AM|PM)" }, a: { g:1, c:"if (results[{0}] == 'am') {{\n" + "if (h == 12) {{ h = 0; }}\n" + "}} else {{ if (h < 12) {{ h += 12; }}}}", s:"(am|pm)" } });
-
29 Oct 2008 5:37 AM #6
interesting... are the double braces (i.e. {{ and }}) specifically for m$ ajax?
and why don't the braces in
need to be escaped?Code:results[{0}] == 'am'
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
29 Oct 2008 5:50 AM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Ext JS String.format specifically replaces '{number}' with the parameter at position <number>.
MS Ajax String.format is a bit more flexible with what can be inside the curly brackets (see specs).
That is why the following format string:
would result in trying to replace the following parameters:Code:"if (results[{0}] == 'AM') {if (h == 12) {h = 0;} else if (h < 12) {h += 12;}}"- {0}
- {if (h == 12) {h = 0;}
- {h += 12;}
This format string:
would correctly only replace the {0} parameter.Code:"if (results[{0}] == 'AM') {{if (h == 12) {{h = 0;}} else if (h < 12) {{h += 12;}}}}"
-
29 Oct 2008 7:12 AM #8
ah ok. escaping the braces. now i get it. d'oh...
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )


Reply With Quote