From 5921a7d83fbf9a452478b93639d1e844b3191fe0 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Mon, 14 Jul 2025 19:54:45 -0700 Subject: [PATCH] Fix rounding of minutes in global stats play duration --- data/interfaces/default/js/script.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 5d75c69d..9f2a92eb 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -288,23 +288,10 @@ function isPrivateIP(ip_address) { } function humanTime(seconds) { - var d = Math.floor(moment.duration(seconds, 'seconds').asDays()); - var h = Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()); - var m = Math.round(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()); - - var text = ''; - if (d > 0) { - text = '

' + d + '

day' + ((d > 1) ? 's' : '') + '

' - + '

' + h + '

hr' + ((h > 1) ? 's' : '') + '

' - + '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; - } else if (h > 0) { - text = '

' + h + '

hr' + ((h > 1) ? 's' : '') + '

' - + '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; - } else { - text = '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; + if (seconds > 0) { + return humanDuration(seconds * 1000).replaceAll(/(\d+) (\w+)/g, '

$1

$2

') } - - return text + return "

0

mins

"; } String.prototype.toProperCase = function () {