aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index bb992c28..b2286249 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -60,11 +60,16 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('VolumeUnits').convertValue(value, Traccar.app.getAttributePreference('volumeUnit'));
},
+ hoursFormatter: function (value) {
+ return Ext.getStore('HoursUnits').formatValue(value, 'h');
+ },
+
+ hoursConverter: function (value) {
+ return Ext.getStore('HoursUnits').convertValue(value, 'h');
+ },
+
durationFormatter: function (value) {
- var hours, minutes;
- hours = Math.floor(value / 3600000);
- minutes = Math.floor(value % 3600000 / 60000);
- return hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation;
+ return Ext.getStore('HoursUnits').formatValue(value, 'h', true);
},
deviceIdFormatter: function (value) {
@@ -251,6 +256,8 @@ Ext.define('Traccar.AttributeFormatter', {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°C');
case 'volume':
return this.volumeFormatter;
+ case 'hours':
+ return this.hoursFormatter;
case 'consumption':
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
default:
@@ -268,6 +275,8 @@ Ext.define('Traccar.AttributeFormatter', {
return this.speedConverter;
case 'volume':
return this.volumeConverter;
+ case 'hours':
+ return this.hoursConverter;
default:
return function (value) {
return value;
@@ -280,6 +289,8 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getAttributePreference('speedUnit', 'kn'), true);
} else if (attribute && attribute.get('dataType') === 'distance') {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getAttributePreference('distanceUnit', 'km'), true);
+ } else if (attribute && attribute.get('dataType') === 'hours') {
+ return Ext.getStore('HoursUnits').formatValue(value, 'h', true);
} else {
return value;
}