2023-06-08 03:08:17 +02:00
|
|
|
export function formatSeconds(secs: number, showHours = false): string {
|
|
|
|
if (Number.isNaN(secs)) {
|
|
|
|
if (showHours) return "0:00:00";
|
|
|
|
return "0:00";
|
|
|
|
}
|
|
|
|
|
|
|
|
let time = secs;
|
|
|
|
const seconds = Math.floor(time % 60);
|
|
|
|
|
|
|
|
time /= 60;
|
|
|
|
const minutes = Math.floor(time % 60);
|
|
|
|
|
|
|
|
time /= 60;
|
|
|
|
const hours = Math.floor(time);
|
|
|
|
|
|
|
|
const paddedSecs = seconds.toString().padStart(2, "0");
|
|
|
|
const paddedMins = minutes.toString().padStart(2, "0");
|
|
|
|
|
|
|
|
if (!showHours) return [paddedMins, paddedSecs].join(":");
|
|
|
|
return [hours, paddedMins, paddedSecs].join(":");
|
|
|
|
}
|
2023-10-21 05:18:02 +02:00
|
|
|
|
|
|
|
export function durationExceedsHour(secs: number): boolean {
|
|
|
|
return secs > 60 * 60;
|
|
|
|
}
|