PDA

View Full Version : [CLOSED] TimeField don't consider the seconds and milliseconds



lucarossi
14 Nov 2013, 1:44 AM
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:


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:


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:


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

Gary Schlosberg
14 Nov 2013, 8:23 AM
Ext.form.field.Time (http://docs.sencha.com/extjs/4.2.1/#!/api/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.