Fix formatting of bus time with milliseconds

pull/237/head
ElementalAlchemist 3 years ago committed by Mike Lang
parent 72b34945bc
commit 344ca041a3

@ -304,6 +304,8 @@ function getBusTimeFromTimeString(timeString) {
remainingBusTimeSeconds %= 3600; remainingBusTimeSeconds %= 3600;
let minutes = Math.floor(remainingBusTimeSeconds / 60); let minutes = Math.floor(remainingBusTimeSeconds / 60);
let seconds = remainingBusTimeSeconds % 60; let seconds = remainingBusTimeSeconds % 60;
let milliseconds = Math.round(seconds % 1 * 1000);
seconds = Math.trunc(seconds);
while (minutes.toString().length < 2) { while (minutes.toString().length < 2) {
minutes = `0${minutes}`; minutes = `0${minutes}`;
@ -312,6 +314,13 @@ function getBusTimeFromTimeString(timeString) {
seconds = `0${seconds}`; seconds = `0${seconds}`;
} }
if (milliseconds > 0) {
while (milliseconds.toString().length < 3) {
milliseconds = `0${milliseconds}`;
}
return `${hours}:${minutes}:${seconds}.${milliseconds}`;
}
return `${hours}:${minutes}:${seconds}`; return `${hours}:${minutes}:${seconds}`;
} }

Loading…
Cancel
Save