mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 17:51:39 -05:00
Update helpers.js
Updated `formatSpeed` in `helpers.js` to correctly assume incoming speed is in m/s and convert to km/h before formatting.
This commit is contained in:
parent
b05ab63f28
commit
69b628a487
1 changed files with 5 additions and 2 deletions
|
|
@ -66,15 +66,18 @@ export function formatDate(timestamp, timezone) {
|
|||
return date.toLocaleString(locale, { timeZone: timezone });
|
||||
}
|
||||
|
||||
export function formatSpeed(speedKmh, unit = 'km') {
|
||||
export function formatSpeed(speedMs, unit = 'km') {
|
||||
const speedKmh = speedMs * 3.6; // Convert m/s to km/h
|
||||
|
||||
if (unit === 'km') {
|
||||
return `${Math.round(speedKmh)} km/h`;
|
||||
} else {
|
||||
const speedMph = speedKmh * 0.621371; // Convert km/h to mph
|
||||
const speedMph = speedKmh * 0.621371;
|
||||
return `${Math.round(speedMph)} mph`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function haversineDistance(lat1, lon1, lat2, lon2, unit = 'km') {
|
||||
// Haversine formula to calculate the distance between two points
|
||||
const toRad = (x) => (x * Math.PI) / 180;
|
||||
|
|
|
|||
Loading…
Reference in a new issue