diff options
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/common/components/PositionValue.js | 6 | ||||
-rw-r--r-- | modern/src/common/util/formatter.js | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js index 6dd1f50d..a851c886 100644 --- a/modern/src/common/components/PositionValue.js +++ b/modern/src/common/components/PositionValue.js @@ -3,7 +3,7 @@ import { useSelector } from 'react-redux'; import { Link } from '@mui/material'; import { Link as RouterLink } from 'react-router-dom'; import { - formatAlarm, formatAltitude, formatBoolean, formatCoordinate, formatCourse, formatDistance, formatNumber, formatPercentage, formatSpeed, formatTime, + formatAlarm, formatAltitude, formatBoolean, formatCoordinate, formatCourse, formatDistance, formatNumber, formatNumericHours, formatPercentage, formatSpeed, formatTime, } from '../util/formatter'; import { useAttributePreference, usePreference } from '../util/preferences'; import { useTranslation } from './LocalizationProvider'; @@ -42,7 +42,7 @@ const PositionValue = ({ position, property, attribute }) => { case 'altitude': return formatAltitude(value, altitudeUnit, t); case 'batteryLevel': - return formatPercentage(value); + return formatPercentage(value, t); case 'alarm': return formatAlarm(value, t); case 'odometer': @@ -50,7 +50,7 @@ const PositionValue = ({ position, property, attribute }) => { case 'totalDistance': return formatDistance(value, distanceUnit, t); case 'hours': - return formatNumber(value / 1000); + return formatNumericHours(value, t); default: if (typeof value === 'number') { return formatNumber(value); diff --git a/modern/src/common/util/formatter.js b/modern/src/common/util/formatter.js index f36b4d38..47bd2cd0 100644 --- a/modern/src/common/util/formatter.js +++ b/modern/src/common/util/formatter.js @@ -41,6 +41,12 @@ export const formatVolume = (value, unit, t) => `${volumeFromLiters(value, unit) export const formatHours = (value) => moment.duration(value).humanize(); +export const formatNumericHours = (value, t) => { + const hours = Math.floor(value / 3600000); + const minutes = Math.floor((value % 3600000) / 60000); + return `${hours} ${t('sharedHourAbbreviation')} ${minutes} ${t('sharedMinuteAbbreviation')}`; +}; + export const formatCoordinate = (key, value, unit) => { let hemisphere; let degrees; |