blob: 9a61b1782b2cd098307a0d36821a4038737c12a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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':
case 'course':
return value.toFixed(1);
case 'batteryLevel':
return value + '%';
default:
return value;
}
}
export default (object, key) => {
if (object != null && typeof object == 'object') {
return formatValue(key, object[key]);
} else {
return formatValue(key, object);
}
};
|