refactor: show both days and hours

This commit is contained in:
Barış Soner Uşaklı
2025-07-17 12:34:52 -04:00
parent 272008bb51
commit 1d7c32a52f

View File

@@ -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() {