Skip to content

Commit 6397912

Browse files
committed
Fix duration formatting in getDuration function: Handle case where rounding produces 60 seconds by incrementing minutes and resetting seconds to 0 for accurate time representation.
1 parent 135b177 commit 6397912

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ function getDuration(string $file): string {
4444
$minutes = (int)floor($duration / 60);
4545
$secondsFloat = round(fmod($duration, 60));
4646
$seconds = (int)$secondsFloat;
47+
// Handle case where rounding produces 60 seconds (e.g., 59.5 rounds to 60)
48+
if ($seconds == 60) {
49+
$minutes++;
50+
$seconds = 0;
51+
}
4752
$duration = sprintf("%d:%02d", $minutes, $seconds);
4853
return $duration;
4954
} catch (Exception $e) {

0 commit comments

Comments
 (0)