blob: ce46c6cff9e96b8797af2bda78f7cfe2b4ebcdab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}
};
|