mass-testing-report: fix bugged formatTime

The `formatTime` function was bugged, returning invalidly formatted
strings when the second components was less than 10. Rework it to emit
proper formatting.
This commit is contained in:
Giacomo Vercesi
2026-03-12 11:44:09 +01:00
committed by Alessandro Di Federico
parent 36b7f39606
commit a746d5afc3
+3 -2
View File
@@ -230,7 +230,8 @@ function populateNav(element: HTMLElement) {
// showHours=false => MM:ss.mmm
// showHours=true => hh:MM:ss.mmm
function formatTime(elapsedSeconds: number, showHours: boolean): string {
const seconds = elapsedSeconds % 60;
const milliseconds = elapsedSeconds.toFixed(3).split(".", 2)[1];
const seconds = padNumber(Math.floor(elapsedSeconds % 60), 2);
let minutes = 0;
let hours = 0;
if (showHours) {
@@ -239,7 +240,7 @@ function formatTime(elapsedSeconds: number, showHours: boolean): string {
} else {
minutes = Math.floor(elapsedSeconds / 60);
}
let res = padNumber(minutes, 2) + ":" + padNumber(truncate(seconds, 3), 2);
let res = `${padNumber(minutes, 2)}:${seconds}.${milliseconds}`;
if (showHours) {
res = padNumber(hours, 2) + ":" + res;
}