From 981d6cbd15b6cb276da9bd8de9bfec918dbfa008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Pomyka=C5=82a?= <37307597+Akasiek@users.noreply.github.com> Date: Thu, 17 Mar 2022 19:05:49 +0100 Subject: [PATCH] Fixed few problems with calculating albums duration --- .../albumPageAside/albumPageAsideTracks.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/react/src/components/albumPage/albumPageAside/albumPageAsideTracks.jsx b/react/src/components/albumPage/albumPageAside/albumPageAsideTracks.jsx index 82b822d..4f19d81 100644 --- a/react/src/components/albumPage/albumPageAside/albumPageAsideTracks.jsx +++ b/react/src/components/albumPage/albumPageAside/albumPageAsideTracks.jsx @@ -25,15 +25,17 @@ const AlbumPageAsideTracks = ({ album }) => { }); // Pass hour or minute if there is more than 60 minutes or seconds - hours = parseInt(hours + minutes / 60); - minutes = minutes % 60; minutes = parseInt(minutes + seconds / 60); seconds = seconds % 60; + hours = parseInt(hours + minutes / 60); + minutes = minutes % 60; // Add leading zero if needed - if (hours / 10 <= 0) hours = "0" + String(hours); - if (minutes / 10 <= 0) minutes = "0" + String(minutes); - if (seconds / 10 <= 0) seconds = "0" + String(seconds); + if (parseInt(hours / 10) <= 0) hours = "0" + String(hours); + if (parseInt(minutes / 10) <= 0) minutes = "0" + String(minutes); + if (parseInt(seconds / 10) <= 0) seconds = "0" + String(seconds); + + console.log(hours, minutes, seconds); // Return as duration string return `${hours}:${minutes}:${seconds}`;