From 40cca106601db71d1c6921ace8ec84238bf74985 Mon Sep 17 00:00:00 2001 From: Jelle van Snik Date: Tue, 17 Jan 2023 13:42:15 +0100 Subject: [PATCH] update time control display --- src/components/video/controls/TimeControl.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/video/controls/TimeControl.tsx b/src/components/video/controls/TimeControl.tsx index 5af152e3..49e933cd 100644 --- a/src/components/video/controls/TimeControl.tsx +++ b/src/components/video/controls/TimeControl.tsx @@ -13,19 +13,17 @@ function formatSeconds(secs: number, showHours = false): string { let time = secs; const seconds = time % 60; - time /= 60; + time = Math.floor(time / 60); const minutes = time % 60; - time /= 60; + time = Math.floor(time / 60); const hours = time; - if (!showHours) - return `${Math.floor(minutes).toString()}:${Math.floor(seconds) - .toString() - .padStart(2, "0")}`; - return `${Math.floor(hours).toString()}:${Math.floor(minutes) - .toString() - .padStart(2, "0")}:${Math.floor(seconds).toString().padStart(2, "0")}`; + const paddedSecs = seconds.toString().padStart(2, "0"); + const paddedMins = minutes.toString().padStart(2, "0"); + + if (!showHours) return [minutes, paddedSecs].join(":"); + return [hours, paddedMins, paddedSecs].join(":"); } interface Props {