From 90af4401e15e2565d9198e9089efd45deea13146 Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Thu, 25 Jan 2024 23:03:05 -0600 Subject: [PATCH] Add song's duration --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 635a756..dc92f26 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,17 @@ app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) }) +function timeFormatter(seconds) { + seconds = Math.ceil(seconds) + var minutes = 0 + while (seconds > 60) { + seconds -= 60 + minutes += 1 + } + + return `${minutes}:${seconds}` +} + function pageUpdate() { var statuses = { "online": { @@ -181,6 +192,7 @@ function pageUpdate() { ${songStats()}
+ ${timeFormatter((activity.timestamps.end - activity.timestamps.start) / 1000)}