Update voice broadcast time display (#9646)

This commit is contained in:
Michael Weimann 2022-11-30 08:47:29 +01:00 committed by GitHub
parent 5f6b1dda8d
commit 70a7961681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 149 additions and 87 deletions

View file

@ -125,6 +125,9 @@ export function formatTime(date: Date, showTwelveHour = false): string {
}
export function formatSeconds(inSeconds: number): string {
const isNegative = inSeconds < 0;
inSeconds = Math.abs(inSeconds);
const hours = Math.floor(inSeconds / (60 * 60)).toFixed(0).padStart(2, '0');
const minutes = Math.floor((inSeconds % (60 * 60)) / 60).toFixed(0).padStart(2, '0');
const seconds = Math.floor(((inSeconds % (60 * 60)) % 60)).toFixed(0).padStart(2, '0');
@ -133,6 +136,10 @@ export function formatSeconds(inSeconds: number): string {
if (hours !== "00") output += `${hours}:`;
output += `${minutes}:${seconds}`;
if (isNegative) {
output = "-" + output;
}
return output;
}