diff --git a/js/app/models/AmdaTimeObject.js b/js/app/models/AmdaTimeObject.js index 303c3bb..6e101ba 100644 --- a/js/app/models/AmdaTimeObject.js +++ b/js/app/models/AmdaTimeObject.js @@ -7,11 +7,7 @@ * * @author elena * @version $Id: AmdaTimeObject.js 1534 2013-05-24 13:30:26Z myriam $ - * @todo Validations - ****************************************************************************** - * FT Id : Date : Name - Description - ****************************************************************************** - * : :07/07/2011: elena – creation + * @todo Validations */ @@ -26,66 +22,70 @@ Ext.define('amdaModel.TTobject', { } }); - Ext.define('amdaModel.AmdaTimeObject', { extend: 'amdaModel.AmdaObject', statics:{ inputTimeSrc: ['TimeTable','Interval','Catalog'] - }, + }, fields : [ - { name: 'resultId', type: 'string'}, - { name: 'folderId', type: 'string'}, - { name: 'processId', type: 'string'}, - { name: 'timesrc', type: 'string'/*, defaultValue: amdaModel.AmdaTimeObject.inputTimeSrc[1] /*'Interval'*/ }, - { name: 'startDate', type: 'date', defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1), - convert: function(value,rec) { - if (!Ext.isDate(value)) { - var valueString = new String(value); - var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); - return date; - } - return value; - } - }, - { name: 'stopDate', type: 'date', defaultValue: Ext.Date.clearTime (new Date()), persist: false, - convert: function(value,rec) { - if (!Ext.isDate(value)){ - var valueString = new String(value); - var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); - return date; - } - return value; - } - - }, - { - name: 'durationDay', type: 'int', - convert: function(value, rec) { - return Ext.String.leftPad(Math.floor((rec.get('stopDate') - rec.get('startDate'))/86400000),4,'0'); - } - }, - { - name: 'durationHour', type: 'int', - convert: function(value, rec) { - var diffH = (rec.get('stopDate') - rec.get('startDate'))/3600000 % 24; - return Ext.String.leftPad(Math.floor(diffH), 2, '0'); - } - }, - { - name: 'durationMin', type: 'int', - convert: function(value, rec) { - var diffM = (rec.get('stopDate') - rec.get('startDate'))/60000 % 60; - return Ext.String.leftPad(Math.floor(diffM), 2, '0'); - } - }, - { - name: 'durationSec', type: 'int', - convert: function(value, rec) { - var diffS = (rec.get('stopDate') - rec.get('startDate'))/1000 % 60; - return Ext.String.leftPad(Math.floor(diffS), 2, '0'); - } - }, - { name: 'timeTables', defaultValue: null } // array of TTobject - ] - + { name: 'resultId', type: 'string'}, + { name: 'folderId', type: 'string'}, + { name: 'processId', type: 'string'}, + { name: 'timesrc', type: 'string'/*, defaultValue: amdaModel.AmdaTimeObject.inputTimeSrc[1] /*'Interval'*/ }, + { name: 'startDate', type: 'date', defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1), + convert: function(value,rec) { + if (!Ext.isDate(value)) { + var valueString = new String(value); + var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); + return date; + } + return value; + } + }, + { + name: 'stopDate', type: 'date', defaultValue: Ext.Date.clearTime (new Date()), persist: false, + convert: function(value,rec) { + if (!Ext.isDate(value)){ + var valueString = new String(value); + var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); + return date; + } + return value; + } + }, + { + name: 'durationDay', type: 'int', + convert: function(value, rec) { + var zoneOffset = rec.get('stopDate').getTimezoneOffset() - rec.get('startDate').getTimezoneOffset(); + + return Ext.String.leftPad(Math.floor((rec.get('stopDate') - rec.get('startDate') - zoneOffset*60000)/86400000),4,'0'); + } + }, + { + name: 'durationHour', type: 'int', + convert: function(value, rec) { + var zoneOffset = rec.get('stopDate').getTimezoneOffset() - rec.get('startDate').getTimezoneOffset(); + var diffH = (rec.get('stopDate') - rec.get('startDate') - zoneOffset*60000)/3600000 % 24; + + return Ext.String.leftPad(Math.floor(diffH), 2, '0'); + } + }, + { + name: 'durationMin', type: 'int', + convert: function(value, rec) { + var diffM = (rec.get('stopDate') - rec.get('startDate'))/60000 % 60; + + return Ext.String.leftPad(Math.floor(diffM), 2, '0'); + } + }, + { + name: 'durationSec', type: 'int', + convert: function(value, rec) { + var diffS = (rec.get('stopDate') - rec.get('startDate'))/1000 % 60; + + return Ext.String.leftPad(Math.floor(diffS), 2, '0'); + } + }, + { name: 'timeTables', defaultValue: null } // array of TTobject + ] }); -- libgit2 0.21.2