diff --git a/assets/js/site.js b/assets/js/site.js index c2453d8..5533d5a 100644 --- a/assets/js/site.js +++ b/assets/js/site.js @@ -246,7 +246,8 @@ function updateServerPeak(name, time, playerCount) { if (end) { timestamp += ' ' + end; } - $('#peak_' + safeNameCopy).html('24h Peak: ' + formatNumber(playerCount) + ' @ ' + timestamp); + var timeLabel = msToTime(publicConfig.graphDuration); + $('#peak_' + safeNameCopy).html(timeLabel + ' Peak: ' + formatNumber(playerCount) + ' @ ' + timestamp); } $(document).ready(function() { diff --git a/assets/js/util.js b/assets/js/util.js index ca2fa92..de0af7a 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -163,8 +163,18 @@ function msToTime(timer) { var minutes = timer % 60; var hours = (timer - minutes) / 60; + var days = Math.floor(hours / 24); + hours -= days * 24; + var string = ''; + // hack: only format days if >1, if === 1 it will format as "24h" instead + if (days > 1) { + string += days + 'd'; + } else if (days === 1) { + hours += 24; + } + if (hours > 0) { string += hours + 'h'; } diff --git a/package-lock.json b/package-lock.json index 580c09e..4d5836f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "minetrack", - "version": "4.0.2", + "version": "4.0.3", "lockfileVersion": 1, "requires": true, "dependencies": {