blob: 50841e15bde1766d57e418ab3df764808abd3127 (
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
|
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);
default:
return value;
}
}
export default (object, key) => {
if (object != null && typeof object == 'object') {
return formatValue(key, object[key]);
} else {
return formatValue(key, object);
}
};
|