mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
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:
committed by
Alessandro Di Federico
parent
36b7f39606
commit
a746d5afc3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user