You found a bug! We've classified it as TOUCH-3816 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    770
    Vote Rating
    28
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default [2.1] Ext.util.Format.date returning wrong date (one day off)

    [2.1] Ext.util.Format.date returning wrong date (one day off)


    On Samsung Galaxy S3 Android 4.0.4,
    (Update: This can be reproduced on any browser, see second post below)
    Ext.util.Format.date is returning the wrong date (one day off).

    Test case:
    Code:
    <!DOCTYPE HTML>
    <html manifest="" lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>Date</title>
        <script type="text/javascript" src="http://docs.sencha.com/touch/2-1/touch-build/sencha-touch-all.js"></script>
        
        <script>
        Ext.onReady(function () {
            document.write(Ext.util.Format.date('2012-12-01', 'F d, Y'));
            document.write('<br><br>');
            document.write(new Date());
        });
        </script>
    </head>
    <body></body>
    </html>
    Actual Result:
    Code:
    November 30, 2012
    
    Mon Dec 10 2012 08:55:53 GMT - 0500 (EST)
    Expected Result:
    Code:
    December 01, 2012
    
    Mon Dec 10 2012 08:55:53 GMT - 0500 (EST)
    This is not reproducible with ST 1's Ext.util.Format.date.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,797
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    770
    Vote Rating
    28
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default


    Fyi,
    I was able to reproduce this issue on an HTC Sensation 4.0.3 as well as on my desktop Chrome.
    Simply set the timezone to EST or any < GMT timezone.

    The native Date.parse method isn't parsing '2012-12-01' as expected, see below:

    Code:
    new Date(Date.parse('2012-12-01'));
    // returns "Fri Nov 30 2012 00:00:00 GMT-0500 (EST)"
    
    new Date(Date.parse('2012/12/01'));
    // returns "Sat Dec 01 2012 00:00:00 GMT-0500 (EST)"
    The Ext.util.Format.date code is first trying to parse the '2012-12-01' date,
    and only if it fails, it replaces the dashes and parses it again.

    So what I did is replacing the dashing before.
    Here's my override:

    Code:
    Ext.define('App.override.util.Format', {
    }, function () {
        var date_without_override = Ext.util.Format.date;
        
        // 
        Ext.util.Format.date = function (value, format) {
            value = value.replace(this.dashesRe, "/");
            
            return date_without_override(value, format);
        };
    });
    See
    http://www.sencha.com/forum/showthre...101#post921101
    on why I'm not using the override pre-processor.

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    4
    Vote Rating
    0
    neophitus is on a distinguished road

      0  

    Default


    I can confirm that this bug affects ExtJS as well... not only Sencha Touch.

  5. #5
    Sencha User sahadat's Avatar
    Join Date
    Jul 2010
    Location
    Montreal
    Posts
    6
    Vote Rating
    0
    sahadat is on a distinguished road

      0  

    Default


    I Solved it this way

    function date_renderer(v,index, rec) {
    var returnVal='';

    returnVal=Ext.util.Format.date(v,'Y-m-d');
    if( returnVal=='NaN-NaN-NaN'){ returnVal=v; }//for IE
    else {//Other Browser
    returnVal=new String(v);//alert(returnVal);
    var x= new Date(returnVal);
    x.setDate(x.getDate()+1);
    x=Ext.util.Format.date(x,'Y-m-d');
    if(x==v){ returnVal= x;} else {x= new Date(v); x.setDate(x.getDate()+0); x= Ext.util.Format.date(x,'Y-m-d');}
    returnVal= x;
    }
    return returnVal;
    }

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    4
    Vote Rating
    0
    neophitus is on a distinguished road

      0  

    Default


    I Solved this in a better way. i Just set type and dataFormat in my Model:

    Code:
     { name: dateField, type: 'date', dateFormat: 'Y-m-d' }

  7. #7
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    This uses the native Javascript Date.parse() method and is therefore subject to its idiosyncrasies.
    Most formats assume the local timezone unless specified. One notable exception is 'YYYY-MM-DD' (note the dashes) which is typically interpreted in UTC and can cause date shifting.
    Using 'YYYY/MM/DD' should fix his issue.

    Documentation has been updated to reflect this issue.

    Sencha Inc

    Jamie Avins

    @jamieavins

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi