diff options
author | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-24 14:26:26 +0530 |
---|---|---|
committer | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2020-11-24 14:26:26 +0530 |
commit | 34ec9a62ac0b65665f15f6e80729495e2558547f (patch) | |
tree | e4294411fad4b24ed82b564b8ae56f6c1759812d /modern/src/common/formatter.js | |
parent | df01e1d751980843506946a194fa9f67489182b1 (diff) | |
download | trackermap-web-34ec9a62ac0b65665f15f6e80729495e2558547f.tar.gz trackermap-web-34ec9a62ac0b65665f15f6e80729495e2558547f.tar.bz2 trackermap-web-34ec9a62ac0b65665f15f6e80729495e2558547f.zip |
Refactoring and Improvements in chart report
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r-- | modern/src/common/formatter.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 8ef00400..b2f305a0 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; + } + } +}; |