mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 06:48:47 +00:00
Unify uptime formatting (#2483)
This commit is contained in:
parent
24e25e8953
commit
e768b1c83a
5 changed files with 36 additions and 62 deletions
|
@ -20,17 +20,14 @@ export default function Uptime({ refresh = 1500 }) {
|
|||
return <Resource icon={FaRegClock} value="-" label={t("resources.uptime")} percentage="0" />;
|
||||
}
|
||||
|
||||
const mo = Math.floor(data.uptime / (3600 * 24 * 31));
|
||||
const d = Math.floor((data.uptime % (3600 * 24 * 31)) / (3600 * 24));
|
||||
const h = Math.floor((data.uptime % (3600 * 24)) / 3600);
|
||||
const m = Math.floor((data.uptime % 3600) / 60);
|
||||
|
||||
let uptime;
|
||||
if (mo > 0) uptime = `${mo}${t("resources.months")} ${d}${t("resources.days")}`;
|
||||
else if (d > 0) uptime = `${d}${t("resources.days")} ${h}${t("resources.hours")}`;
|
||||
else uptime = `${h}${t("resources.hours")} ${m}${t("resources.minutes")}`;
|
||||
|
||||
const percent = Math.round((new Date().getSeconds() / 60) * 100).toString();
|
||||
|
||||
return <Resource icon={FaRegClock} value={uptime} label={t("resources.uptime")} percentage={percent} />;
|
||||
return (
|
||||
<Resource
|
||||
icon={FaRegClock}
|
||||
value={t("common.uptime", { value: data.uptime })}
|
||||
label={t("resources.uptime")}
|
||||
percentage={percent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue