aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/formatter.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r--modern/src/common/formatter.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 8ef0040..b2f305a 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -9,7 +9,7 @@ export const formatPosition = (value, key) => {
case 'fixTime':
case 'deviceTime':
case 'serverTime':
- return moment(value).format('YYYY-MM-DD HH:mm');
+ return moment(value).format('LLL');
case 'latitude':
case 'longitude':
return value.toFixed(5);
@@ -80,3 +80,26 @@ export const formatVolume = (value, unit) => {
export const formatHours = (value) => {
return moment.duration(value).humanize();
};
+
+const speedConverter = (value, unit) => {
+ switch (unit) {
+ case 'kmh':
+ return (value * 1.852).toFixed(2);
+ case 'mph':
+ return (value * 1.15078).toFixed(2);
+ case 'kn':
+ default:
+ return (value * 1).toFixed(2);
+ }
+};
+
+export const getConverter = (key) => {
+ switch (key) {
+ case 'speed':
+ return speedConverter;
+ default:
+ return function (value) {
+ return value;
+ }
+ }
+};