4dca4f0aa9
* 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
15 lines
479 B
TypeScript
15 lines
479 B
TypeScript
import React from 'react';
|
|
|
|
export default ({ uptime }: { uptime: number }) => {
|
|
const days = Math.floor(uptime / (24 * 60 * 60));
|
|
const hours = Math.floor(Math.floor(uptime) / 60 / 60 % 24);
|
|
const remainder = Math.floor(uptime - (hours * 60 * 60));
|
|
const minutes = Math.floor(remainder / 60 % 60);
|
|
const seconds = remainder % 60;
|
|
|
|
if (days > 0) {
|
|
return <>{days}d {hours}h {minutes}m</>;
|
|
}
|
|
|
|
return <>{hours}h {minutes}m {seconds}s</>;
|
|
};
|