Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Jan 2012
    Posts
    27
    Vote Rating
    1
    lucarossi is on a distinguished road

      1  

    Default TimeField don't consider the seconds and milliseconds

    TimeField don't consider the seconds and milliseconds


    Ext version tested:
    Ext 4.2.2 - bug is present
    Ext 4.2.1 - bug is NOT present

    Browser versions tested:
    Chrome 30 - fails
    FF25 (firebug 1.12.4 installed) - fails
    IE9 - fails

    Description:

    When i use a timefield like this:

    Code:
    var eventTime = Ext.create('Ext.form.field.Time',{
        format: 'G:i:s',
        submitFormat: 'Hisu',
        fieldLabel: 'Time',
        id : 'eventTime_id',
        name : 'eventTime',
        labelWidth: 30,
        inputWidth: 70,
        labelAlign: 'right'});
    and i try to set value:

    Code:
    var timeValue = '112404';
        var dateValue= Ext.Date.parse('20130101', 'Ymd');
        dateValue= Ext.Date.clearTime(dateValue);
        dateValue.setHours(Math.floor(timeValue/10000),Math.floor((timeValue%10000)/100),Math.floor(timeValue%100));
        Ext.getCmp('eventTime_id').setValue(dateValue);
    the seconds becames '0'.

    I fix the problem modifying the code of setInitDate method and its use in setValue method, like this:

    Code:
    getInitDate: function(hours, minutes, seconds, milliseconds) {
            var parts = this.initDateParts;
            return new Date(parts[0], parts[1], parts[2], hours || 0, minutes || 0, seconds || 0, milliseconds || 0);    
    }
    
    setValue: function(v) {
           
            this.getPicker();
            if (Ext.isDate(v)) {
                value = this.getInitDate(v.getHours(), v.getMinutes(),v.getSeconds(),v.getMilliseconds());
            }
            
            return this.callParent([v]);
    }
    now works good for my needs but i'm not sure it's a real bugs and if my solution is ok. can you help me?


    All the best,
    Luca

  2. #2
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,854
    Vote Rating
    66
    Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about

      0  

    Default


    Ext.form.field.Time doesn't support seconds or milliseconds, so I wouldn't call it a bug. I'm surprised this was working for you in 4.2.1. If you need to support that level of detail, then I believe overriding with a change like yours is your best option.
    Get on the Fast Track with Sencha Training http://sencha.com/training

Thread Participants: 1