Show time left for voice broadcast recordings (#9564)

This commit is contained in:
Michael Weimann 2022-11-10 11:53:49 +01:00 committed by GitHub
parent 962e8e0b23
commit f6347d24ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 469 additions and 145 deletions

View file

@ -149,6 +149,31 @@ export function formatSeconds(inSeconds: number): string {
return output;
}
export function formatTimeLeft(inSeconds: number): string {
const hours = Math.floor(inSeconds / (60 * 60)).toFixed(0);
const minutes = Math.floor((inSeconds % (60 * 60)) / 60).toFixed(0);
const seconds = Math.floor(((inSeconds % (60 * 60)) % 60)).toFixed(0);
if (hours !== "0") {
return _t("%(hours)sh %(minutes)sm %(seconds)ss left", {
hours,
minutes,
seconds,
});
}
if (minutes !== "0") {
return _t("%(minutes)sm %(seconds)ss left", {
minutes,
seconds,
});
}
return _t("%(seconds)ss left", {
seconds,
});
}
const MILLIS_IN_DAY = 86400000;
function withinPast24Hours(prevDate: Date, nextDate: Date): boolean {
return Math.abs(prevDate.getTime() - nextDate.getTime()) <= MILLIS_IN_DAY;