Skip to content

Node.js based forum software built for the modern web

refactor: show both days and hours

Barış Soner Uşaklı1d7c32a52f29
diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js
index 6f63faf8a9..3c0457cd82 100644
--- a/src/controllers/admin/info.js
+++ b/src/controllers/admin/info.js
@@ -117,14 +117,18 @@ function getCpuUsage() {
}
function humanReadableUptime(seconds) {
+ const oneHourInSeconds = 3600;
+ const oneDayInSeconds = oneHourInSeconds * 24;
if (seconds < 60) {
return `${Math.floor(seconds)}s`;
- } else if (seconds < 3600) {
+ } else if (seconds < oneHourInSeconds) {
return `${Math.floor(seconds / 60)}m`;
- } else if (seconds < 3600 * 24) {
+ } else if (seconds < oneDayInSeconds) {
return `${Math.floor(seconds / (60 * 60))}h`;
}
- return `${Math.floor(seconds / (60 * 60 * 24))}d`;
+ const days = Math.floor(seconds / (oneDayInSeconds));
+ const hours = Math.floor((seconds % (oneDayInSeconds)) / oneHourInSeconds);
+ return `${days}d ${hours}h`;
}
async function getGitInfo() {