1. #1
    Sencha User
    Join Date
    Apr 2008
    Posts
    14
    Vote Rating
    0
    xplicit is on a distinguished road

      0  

    Default [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


    Code:
    var dt=Date.parseDate('10/20/2008 10:10:00 AM','m/d/Y h:i:s A');
    Causes js error in IE7.

    Code:
    var dt=Date.parseDate('10/20/2008 10:10:00','m/d/Y h:i:s');
    Works fine.

    In ext 2.0.2 this function works correctly.

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    4
    mystix will become famous soon enough

      0  

    Default


    i just tried this in FF3/IE6 using stock 2.2:
    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"));
        }    
    });
    and it works as expected.

    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?

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,103
    Vote Rating
    500
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Fine for me, IE7.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User
    Join Date
    Apr 2008
    Posts
    14
    Vote Rating
    0
    xplicit is on a distinguished road

      0  

    Default 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.

  5. #5
    Sencha User
    Join Date
    Apr 2008
    Posts
    14
    Vote Rating
    0
    xplicit is on a distinguished road

      0  

    Default


    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)"
            }
    });

  6. #6
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    4
    mystix will become famous soon enough

      0  

    Default


    interesting... are the double braces (i.e. {{ and }}) specifically for m$ ajax?

    and why don't the braces in
    Code:
    results[{0}] == 'am'
    need to be escaped?

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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:
    Code:
    "if (results[{0}] == 'AM') {if (h == 12) {h = 0;} else if (h < 12) {h += 12;}}"
    would result in trying to replace the following parameters:
    • {0}
    • {if (h == 12) {h = 0;}
    • {h += 12;}
    (an fail of course)

    This format string:
    Code:
    "if (results[{0}] == 'AM') {{if (h == 12) {{h = 0;}} else if (h < 12) {{h += 12;}}}}"
    would correctly only replace the {0} parameter.

  8. #8
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    4
    mystix will become famous soon enough

      0  

    Default


    ah ok. escaping the braces. now i get it. d'oh...

Thread Participants: 3

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar