Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-7418 in a recent build.
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    2
    Vote Rating
    0
    jdamour is on a distinguished road

      0  

    Default Ext-JS 4.1.1a : Ext.Date.add() has daylight savings error with 'h', 'mi', 's', 'ms'

    Ext-JS 4.1.1a : Ext.Date.add() has daylight savings error with 'h', 'mi', 's', 'ms'


    Ext version tested:
    • Ext 4.1.1a
    Browser versions tested against:
    • IE7
    • FF15.0.1 (firebug 1.7.3 installed)
    DOCTYPE tested against:
    • HTML
    Description:
    • Please see DETAILS: below.
    Steps to reproduce the problem:
    • Set your computer to Eastern US time zone, and to respect Daylight Savings.
    • var mar11 = new Date(1331442000); // midnight March 11, 2012
    • var nov4 = new Date(1352001600); // midnight November 4, 2012
    The result that was expected:
    • Ninety two calls of "mar11 = Ext.Date.add( mar11 , 'mi', 15 );" should get you from midnight March 10, 2012 to midnight March 11, 2012
    • One hundred calls of "nov4 = Ext.Date.add( nov4 , 'mi', 15 );" should get you from midnight November 3, 2012 to midnight November 4, 2012
    The result that occurs instead:
    • You can never get to midnight March 11, 2012 if you start at midnight March 10, 2012 and call Ext.Date.add() with an interval of 'h', 'mi', 's', or 'ms'.
    • Ninety six calls of "nov4 = Ext.Date.add( nov4 , 'mi', 15 );" gets you from midnight November 3, 2012 to midnight November 4, 2012
    Recommended fix:
    • Use Date class' setTime() and getTime() methods in the MILLI, SECOND, MINUTE, and HOUR cases of the switch on the interval (example of use in test case below).
    DETAILS:
    The Ext.Date.add() method does not correctly handle hour, minute, second, and millisecond intervals around Daylight Savings Time boundaries. This is the *real* root cause of the Ext.form.TimeField error (a closed bug in the Ext 3.x Bugs forum: link) and the work-around described in that thread (basically, list times from a different day of the year that doesn't have the transition) ended up being used in Ext.picker.Time class in Ext-JS 4.0. Which is fine for time entry fields, but it is still broken.

    The correct solution is to call the Date class' setTime() method instead of setHours(), setMinutes(), setSeconds(), or setMilliseconds(). The cases for day, month, and year are fine the way they are.

    The test case HTML file below demonstrates the problem on computers configured to use any US Daylight Savings Time timezone (your milage may vary in other countries). It also supplies the fix. Please adjust the "src" attribute of the first <script> element if your web root doesn't have ext-all.js in its "lib" subdirectory.
    The test case *tries* to list all times on March 11, 2012 in 15 minute increments, but it keeps resetting to 1:00 AM (this is the source of the infinite loop in the closed bug, which is worked around in Ext.picker.Time). The first TODO line will shift the test date to November 4, 2012 in which a whole hour is lost (adding 15 minutes to "12:45 AM EDT", epoch 1352004300, results in "1:00 AM EST", epoch 1352008800, instead of "1:00 AM EDT", epoch 1352005200).

    Uncomment the lines at the second TODO to apply my fix to the Ext.Date.add() method and re-run both test dates. With my fix in place, November 4, 2012 correctly has 25 hours in its day and March 11, 2012 has 23.

    Test Case:
    Code:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Ext.Date.add() Testcase</title>
    <script type="text/javascript" src="lib/ext-all.js"></script>
    
    <script type="text/javascript" >
    Ext.require([
        'Ext.container.*'
    ]);
    function fixDateAdd () {
     Ext.override(Ext.Date, {
        add : function(date, interval, value) {
            var d = Ext.Date.clone(date),
                day;
            if (!interval || value === 0) {
                return d;
            }
            switch(interval.toLowerCase()) {
                case Ext.Date.MILLI:
        // Use epoch to handle Daylight Savings Time
                    d.setTime(d.getTime() + value);
                    break;
                case Ext.Date.SECOND:
        // Use epoch to handle Daylight Savings Time
                    d.setTime(d.getTime() + value*1000);
                    break;
                case Ext.Date.MINUTE:
        // Use epoch to handle Daylight Savings Time
                    d.setTime(d.getTime() + value*60*1000);
                    break;
                case Ext.Date.HOUR:
        // Use epoch to handle Daylight Savings Time
                    d.setTime(d.getTime() + value*60*60*1000);
                    break;
                case Ext.Date.DAY:
                    d.setDate(d.getDate() + value);
                    break;
                case Ext.Date.MONTH:
                    day = date.getDate();
                    if (day > 28) {
                        day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.MONTH, value)).getDate());
                    }
                    d.setDate(day);
                    d.setMonth(date.getMonth() + value);
                    break;
                case Ext.Date.YEAR:
                    day = date.getDate();
                    if (day > 28) {
                        day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.YEAR, value)).getDate());
                    }
                    d.setDate(day);
                    d.setFullYear(date.getFullYear() + value);
                    break;
            }
            return d;
        }
     });
    }
    Ext.onReady(function() {
     var utilDate = Ext.Date;
     var min = utilDate.clearTime(new Date(2012,2,11)); // TODO : try (2012,10,4)
     var max = utilDate.add( min, Ext.Date.DAY, 1 );
     var body = Ext.getBody();
     var format = 'H:i T (P) U';
     var increment = 15; // minutes
     var maxLoops = 1+( max.getTime() - min.getTime() )/( 1000*increment*60 );
     var timeValues = [{html: '<h1>Listing Times</h1>'}];
     var lastTime = min.getTime();
     
    // // TODO : Un-comment out these lines to fix the problem.
    // fixDateAdd();
     
     var numLoops = 0;
     while(min <= max){
      // In the Fall, the current Ext.Date.add() method jumps an hour ahead.
      // I.e. 12:55 AM EDT + 15 minutes becomes 1:10 AM EST instead of 1:10 AM EDT
      if (min.getTime() > (lastTime + increment*60*1000))
       timeValues.push( {html:'<h5>Time Warp Encountered!</h5>'} );
      lastTime = min.getTime();
      
      
      timeValues.push( {html: 'loop '+numLoops+': '+utilDate.dateFormat(min, format)} );
      min = utilDate.add(min, 'mi', increment);
      
      // In the Spring, the current Ext.Date.add() method jumps an hour backwards.
      // I.e. 1:55 AM EST + 15 minutes becomes 1:10 AM EST instead of 1:10 AM EDT
      numLoops = numLoops + 1;
      if (numLoops > maxLoops)
      {
       timeValues.push( {html: '<em>Exiting infinite loop!</em>'} );
       break;
      }
        }
     
        var view = Ext.create('Ext.Viewport', {items: timeValues} );
    });
    </script>
    </head>
    <body>
    </body>
    </html>

  2. #2
    Sencha User
    Join Date
    Oct 2012
    Posts
    2
    Vote Rating
    0
    jdamour is on a distinguished road

      0  

    Default Forgot to add tags to this post.

    Forgot to add tags to this post.


    Could some administrator add tags to this posting? I recommend: date class, time picker, bug report, fix, and dst.

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