converts trail duration to seconds

This commit is contained in:
Christian Beutel
2025-06-25 15:59:56 +02:00
parent 4ab112e61b
commit 54d7357603
10 changed files with 57 additions and 15 deletions

View File

@@ -1,16 +1,16 @@
import { browser } from "$app/environment";
import { page } from "$app/state";
import { get } from "svelte/store";
export function formatTimeHHMM(minutes?: number) {
if (!minutes) {
export function formatTimeHHMM(seconds?: number) {
if (seconds == null || isNaN(seconds)) {
return "-";
}
const m = minutes % 60;
const h = (minutes - m) / 60;
const totalMinutes = Math.floor(seconds / 60);
const m = totalMinutes % 60;
const h = Math.floor(totalMinutes / 60);
return (h < 10 ? "0" : "") + h.toString() + "h " + (Math.round(m) < 10 ? "0" : "") + Math.round(m).toString() + "m";
return (h < 10 ? "0" : "") + h.toString() + "h " + (m < 10 ? "0" : "") + m.toString() + "m";
}
export function formatDistance(meters?: number) {

View File

@@ -62,7 +62,7 @@ export async function gpx2trail(gpxString: string, fallbackName?: string, f: (ur
.substring(0, 10);
}
trail.duration = totals.duration / 1000 / 60
trail.duration = totals.duration / 1000
trail.elevation_gain = totals.elevationGain;
trail.elevation_loss = totals.elevationLoss;
trail.distance = totals.distance