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

@@ -120,7 +120,7 @@
>
<span
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
log.duration ? log.duration / 60 : undefined,
log.duration ? log.duration : undefined,
)}</span
>
<span

View File

@@ -155,7 +155,7 @@
{formatElevation(log.elevation_loss)}
</td>
<td>
{formatTimeHHMM(log.duration ? log.duration / 60 : undefined)}
{formatTimeHHMM(log.duration ? log.duration : undefined)}
</td>
{#if showCategory}
<td>

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

View File

@@ -959,7 +959,7 @@ export class ElevationProfile {
if (time) {
const timePrevious = this.times[i - 1];
const timeDelta = (time.getTime() - timePrevious.getTime()) / (1000 * 60);
const timeDelta = (time.getTime() - timePrevious.getTime()) / (1000);
cumulatedTime += timeDelta;
this.cumulatedTime.push(cumulatedTime)
}