fix negative time display (#153)

This commit is contained in:
Snarling
2022-10-24 20:09:10 -04:00
committed by GitHub
parent df70458e4f
commit d7193ca8ff
2 changed files with 8 additions and 9 deletions
+3 -2
View File
@@ -7,7 +7,8 @@ e.g. 10000 -> "10 seconds"
120000 -> "2 minutes and 0 seconds"
*/
function convertTimeMsToTimeElapsedString(time: number, showMilli = false): string {
time = Math.floor(time);
const negFlag = time < 0;
time = Math.abs(Math.floor(time));
const millisecondsPerSecond = 1000;
const secondPerMinute = 60;
const minutesPerHours = 60;
@@ -47,7 +48,7 @@ function convertTimeMsToTimeElapsedString(time: number, showMilli = false): stri
}
res += `${seconds} second${!showMilli && secTruncMinutes === 1 ? "" : "s"}`;
return res;
return negFlag ? `-(${res})` : res;
}
// Finds the longest common starting substring in a set of strings