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.js23
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);
+ }
+};