converts trail duration to seconds
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user