Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Mar 2012
    Posts
    2
    Vote Rating
    0
    davidsj is on a distinguished road

      0  

    Question Loss of Millisecond precision date format and parsing using 'c' ISO 8601 format'

    Loss of Millisecond precision date format and parsing using 'c' ISO 8601 format'


    When using the c format to read in data and then post it back to server I'm losing millisecond precision on the formatting. I tracked this down to the Ext.date classes implementation of c in the formatCodes:

    PHP Code:
            c: function() { // ISO-8601 -- GMT format           
                
    for (var "Y-m-dTH:i:sP"code = [], 0c.lengthl; ++i) {
                    var 
    c.charAt(i);
                    
    code.push(== "T" "'T'" utilDate.getFormatCode(e)); // treat T as a character literal 
                 
    }            
                 return 
    code.join(" + ");
            }, 

    The lack of the a .u between the s and P in the for loop means that milliseconds will not sent back to the server when using 'c' as the submitFormat on a timeField in a form.

    The following code demonstrates that using 'c' works fine to set the millisecond precision on a date when parsing, but the precision is lost when formatting the date using 'c'.

    PHP Code:
                var date Ext.Date.parse('2008-07-30T23:00:00.123-07:00''c')
                
    console.log('Milliseconds: ' date.getMilliseconds());  // returns 123
                
    console.log(Ext.Date.format(date'c'));
                
    console.log('Milliseconds: ' Ext.Date.parse(Ext.Date.format(date'c'), 'c').getMilliseconds());  // should return 123 
    if '.u' is added in the format string at the appropriate spot, precision is not lost:

    PHP Code:
                // Same as 'c' only with millisecond precision. Add .u between s and P.
                
    Ext.Date.formatCodes.= function() { // ISO-8601 -- GMT format
                    
    for (var "Y-m-dTH:i:s.uP"code = [], 0c.lengthl; ++i) {
                        var 
    c.charAt(i);
                        
    code.push(== "T" "'T'" Ext.Date.getFormatCode(e)); // treat T as a character literal
                    
    }
                    return 
    code.join(" + ");
                };
                
    console.log(Ext.Date.format(date'x'));
                
    console.log('Milliseconds: ' Ext.Date.parse(Ext.Date.format(date'x'), 'c').getMilliseconds()); 
    I can of course override c as demonstrated above, but before I do that I wanted to understand the reasoning behind not including the milliseconds in the formatting to begin with. Was it simply a stylistic choice or was there a functional reason behind it?

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,536
    Vote Rating
    380
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Do you want me to move this thread to Bugs?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2012
    Posts
    2
    Vote Rating
    0
    davidsj is on a distinguished road

      0  

    Default


    Yes. Please move the thread to bugs. Thank You.

Thread Participants: 1