From ede3e0556e838b92f66ed55ffd25635bb14feb1d Mon Sep 17 00:00:00 2001 From: WardPearce Date: Tue, 26 Mar 2024 19:06:37 +1300 Subject: [PATCH] Minor improvements to thumbnail timestamps --- materialious/src/lib/misc.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/materialious/src/lib/misc.ts b/materialious/src/lib/misc.ts index 83f052f7..6b423735 100644 --- a/materialious/src/lib/misc.ts +++ b/materialious/src/lib/misc.ts @@ -15,8 +15,17 @@ export function cleanNumber(number: number): string { export function videoLength(lengthSeconds: number): string { const hours = Math.floor(lengthSeconds / 3600); - const minutes = Math.floor((lengthSeconds % 3600) / 60); - const seconds = lengthSeconds % 60; + let minutes: number | string = Math.floor((lengthSeconds % 3600) / 60); + let seconds: number | string = lengthSeconds % 60; + + if (minutes < 10) { + minutes = `0${minutes}`; + } + + if (seconds < 10) { + seconds = `0${seconds}`; + } + if (hours !== 0) { return `${hours}:${minutes}:${seconds}`;