do not use locale time string, gives different formats and causes errors

This commit is contained in:
vcoppe
2024-09-12 16:05:54 +02:00
parent 3e57bdc7c8
commit 9a0d54c684

View File

@@ -39,6 +39,10 @@
return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate()); return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
} }
function toTimeString(date: Date): string {
return date.toTimeString().split(' ')[0];
}
const { velocityUnits, distanceUnits } = settings; const { velocityUnits, distanceUnits } = settings;
function setSpeed(value: number) { function setSpeed(value: number) {
@@ -52,14 +56,14 @@
function setGPXData() { function setGPXData() {
if ($gpxStatistics.global.time.start) { if ($gpxStatistics.global.time.start) {
startDate = toCalendarDate($gpxStatistics.global.time.start); startDate = toCalendarDate($gpxStatistics.global.time.start);
startTime = $gpxStatistics.global.time.start.toLocaleTimeString(); startTime = toTimeString($gpxStatistics.global.time.start);
} else { } else {
startDate = undefined; startDate = undefined;
startTime = undefined; startTime = undefined;
} }
if ($gpxStatistics.global.time.end) { if ($gpxStatistics.global.time.end) {
endDate = toCalendarDate($gpxStatistics.global.time.end); endDate = toCalendarDate($gpxStatistics.global.time.end);
endTime = $gpxStatistics.global.time.end.toLocaleTimeString(); endTime = toTimeString($gpxStatistics.global.time.end);
} else { } else {
endDate = undefined; endDate = undefined;
endTime = undefined; endTime = undefined;
@@ -103,7 +107,7 @@
: 1; : 1;
let end = new Date(start.getTime() + ratio * movingTime * 1000); let end = new Date(start.getTime() + ratio * movingTime * 1000);
endDate = toCalendarDate(end); endDate = toCalendarDate(end);
endTime = end.toLocaleTimeString(); endTime = toTimeString(end);
} }
} }
@@ -119,7 +123,7 @@
: 1; : 1;
let start = new Date(end.getTime() - ratio * movingTime * 1000); let start = new Date(end.getTime() - ratio * movingTime * 1000);
startDate = toCalendarDate(start); startDate = toCalendarDate(start);
startTime = start.toLocaleTimeString(); startTime = toTimeString(start);
} }
} }