From 344ca041a3ac9aad11f65504224e6064cf5e253e Mon Sep 17 00:00:00 2001 From: ElementalAlchemist Date: Sun, 17 Oct 2021 11:00:38 -0500 Subject: [PATCH] Fix formatting of bus time with milliseconds --- thrimbletrimmer/scripts/edit.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/thrimbletrimmer/scripts/edit.js b/thrimbletrimmer/scripts/edit.js index b264358..b99ed54 100644 --- a/thrimbletrimmer/scripts/edit.js +++ b/thrimbletrimmer/scripts/edit.js @@ -304,6 +304,8 @@ function getBusTimeFromTimeString(timeString) { remainingBusTimeSeconds %= 3600; let minutes = Math.floor(remainingBusTimeSeconds / 60); let seconds = remainingBusTimeSeconds % 60; + let milliseconds = Math.round(seconds % 1 * 1000); + seconds = Math.trunc(seconds); while (minutes.toString().length < 2) { minutes = `0${minutes}`; @@ -312,6 +314,13 @@ function getBusTimeFromTimeString(timeString) { seconds = `0${seconds}`; } + if (milliseconds > 0) { + while (milliseconds.toString().length < 3) { + milliseconds = `0${milliseconds}`; + } + return `${hours}:${minutes}:${seconds}.${milliseconds}`; + } + return `${hours}:${minutes}:${seconds}`; }