diff options
-rw-r--r-- | modern/src/common/components/PositionValue.jsx | 3 | ||||
-rw-r--r-- | modern/src/common/util/formatter.js | 12 |
2 files changed, 10 insertions, 5 deletions
diff --git a/modern/src/common/components/PositionValue.jsx b/modern/src/common/components/PositionValue.jsx index 60476177..9c49b7e7 100644 --- a/modern/src/common/components/PositionValue.jsx +++ b/modern/src/common/components/PositionValue.jsx @@ -13,7 +13,6 @@ import { formatNumericHours, formatPercentage, formatSpeed, - formatSpeedKph, formatTime, formatTemperature, formatVoltage, @@ -56,7 +55,7 @@ const PositionValue = ({ position, property, attribute }) => { case 'speed': return value != null ? formatSpeed(value, speedUnit, t) : ''; case 'obdSpeed': - return value != null ? formatSpeedKph(value, speedUnit, t) : ''; + return value != null ? formatSpeed(value, speedUnit, t, 'kmh') : ''; case 'course': return formatCourse(value); case 'altitude': diff --git a/modern/src/common/util/formatter.js b/modern/src/common/util/formatter.js index 79f51fce..332cb07e 100644 --- a/modern/src/common/util/formatter.js +++ b/modern/src/common/util/formatter.js @@ -63,9 +63,15 @@ export const formatDistance = (value, unit, t) => `${distanceFromMeters(value, u export const formatAltitude = (value, unit, t) => `${altitudeFromMeters(value, unit).toFixed(2)} ${altitudeUnitString(unit, t)}`; -export const formatSpeed = (value, unit, t) => `${speedFromKnots(value, unit).toFixed(2)} ${speedUnitString(unit, t)}`; - -export const formatSpeedKph = (value, unit, t) => `${speedFromKph(value, unit).toFixed(2)} ${speedUnitString(unit, t)}`; +export const formatSpeed = (value, unit, t, convertFrom='kn') => { + switch (convertFrom){ + case 'kmh': + return `${speedFromKph(value, unit).toFixed(2)} ${speedUnitString(unit, t)}`; + case 'kn': + default: + return `${speedFromKnots(value, unit).toFixed(2)} ${speedUnitString(unit, t)}`; + } +}; export const formatVolume = (value, unit, t) => `${volumeFromLiters(value, unit).toFixed(2)} ${volumeUnitString(unit, t)}`; |