Skip to content

Commit 4dca4f0

Browse files
authored
change display format of the container uptime (pterodactyl#3706)
* change display format of the container uptime Display `day, hour, min` if days is more than 0, otherwise default to existing `hour, min, sec`. Removes pads to make it more clean in this new format. * clean the return
1 parent c4ab318 commit 4dca4f0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

resources/scripts/components/server/ServerDetailsBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const ServerDetailsBlock = () => {
9292
/>
9393
 {!status ? 'Connecting...' : (isInstalling ? 'Installing' : (isTransferring) ? 'Transferring' : status)}
9494
{stats.uptime > 0 &&
95-
<span css={tw`ml-2`}>
95+
<span css={tw`ml-2 lowercase`}>
9696
(<UptimeDuration uptime={stats.uptime / 1000}/>)
9797
</span>
9898
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React from 'react';
22

33
export default ({ uptime }: { uptime: number }) => {
4-
const hours = Math.floor(Math.floor(uptime) / 60 / 60);
4+
const days = Math.floor(uptime / (24 * 60 * 60));
5+
const hours = Math.floor(Math.floor(uptime) / 60 / 60 % 24);
56
const remainder = Math.floor(uptime - (hours * 60 * 60));
6-
const minutes = Math.floor(remainder / 60);
7+
const minutes = Math.floor(remainder / 60 % 60);
78
const seconds = remainder % 60;
89

9-
return (
10-
<>
11-
{hours.toString().padStart(2, '0')}:{minutes.toString().padStart(2, '0')}:{seconds.toString().padStart(2, '0')}
12-
</>
13-
);
10+
if (days > 0) {
11+
return <>{days}d {hours}h {minutes}m</>;
12+
}
13+
14+
return <>{hours}h {minutes}m {seconds}s</>;
1415
};

0 commit comments

Comments
 (0)