diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-25 12:36:19 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-25 12:36:19 -0700 |
commit | d69bb2b2c3053c2c61e4e5d7029751debcfb0dd9 (patch) | |
tree | a8acdb87aea6c39ba1c0712186a2be1dadaff181 /modern/src/common/formatter.js | |
parent | 94be29b98ef9ca509c38c2576dc56828a788937e (diff) | |
download | trackermap-web-d69bb2b2c3053c2c61e4e5d7029751debcfb0dd9.tar.gz trackermap-web-d69bb2b2c3053c2c61e4e5d7029751debcfb0dd9.tar.bz2 trackermap-web-d69bb2b2c3053c2c61e4e5d7029751debcfb0dd9.zip |
Implement simple route report
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r-- | modern/src/common/formatter.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js new file mode 100644 index 00000000..ce46c6cf --- /dev/null +++ b/modern/src/common/formatter.js @@ -0,0 +1,23 @@ +import moment from 'moment'; + +const formatValue = (key, value) => { + switch (key) { + case 'fixTime': + return moment(value).format('LLL'); + case 'latitude': + case 'longitude': + return value.toFixed(5); + case 'speed': + return value.toFixed(1); + default: + return value; + } +} + +export default (object, key) => { + if (object != null && typeof object == 'object') { + return formatValue(key, object[key]); + } else { + return formatValue(key, object); + } +}; |