From 9a0d54c6844768294f1ccb449ff26873dcb0e3b1 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Thu, 12 Sep 2024 16:05:54 +0200 Subject: [PATCH] do not use locale time string, gives different formats and causes errors --- website/src/lib/components/toolbar/tools/Time.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/website/src/lib/components/toolbar/tools/Time.svelte b/website/src/lib/components/toolbar/tools/Time.svelte index 509735d8..bfea92fe 100644 --- a/website/src/lib/components/toolbar/tools/Time.svelte +++ b/website/src/lib/components/toolbar/tools/Time.svelte @@ -39,6 +39,10 @@ return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate()); } + function toTimeString(date: Date): string { + return date.toTimeString().split(' ')[0]; + } + const { velocityUnits, distanceUnits } = settings; function setSpeed(value: number) { @@ -52,14 +56,14 @@ function setGPXData() { if ($gpxStatistics.global.time.start) { startDate = toCalendarDate($gpxStatistics.global.time.start); - startTime = $gpxStatistics.global.time.start.toLocaleTimeString(); + startTime = toTimeString($gpxStatistics.global.time.start); } else { startDate = undefined; startTime = undefined; } if ($gpxStatistics.global.time.end) { endDate = toCalendarDate($gpxStatistics.global.time.end); - endTime = $gpxStatistics.global.time.end.toLocaleTimeString(); + endTime = toTimeString($gpxStatistics.global.time.end); } else { endDate = undefined; endTime = undefined; @@ -103,7 +107,7 @@ : 1; let end = new Date(start.getTime() + ratio * movingTime * 1000); endDate = toCalendarDate(end); - endTime = end.toLocaleTimeString(); + endTime = toTimeString(end); } } @@ -119,7 +123,7 @@ : 1; let start = new Date(end.getTime() - ratio * movingTime * 1000); startDate = toCalendarDate(start); - startTime = start.toLocaleTimeString(); + startTime = toTimeString(start); } }