Skip to content

Commit

Permalink
do not use locale time string, gives different formats and causes errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vcoppe committed Sep 12, 2024
1 parent 3e57bdc commit 9a0d54c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions website/src/lib/components/toolbar/tools/Time.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -103,7 +107,7 @@
: 1;
let end = new Date(start.getTime() + ratio * movingTime * 1000);
endDate = toCalendarDate(end);
endTime = end.toLocaleTimeString();
endTime = toTimeString(end);
}
}
Expand All @@ -119,7 +123,7 @@
: 1;
let start = new Date(end.getTime() - ratio * movingTime * 1000);
startDate = toCalendarDate(start);
startTime = start.toLocaleTimeString();
startTime = toTimeString(start);
}
}
Expand Down

0 comments on commit 9a0d54c

Please sign in to comment.