return time string
This commit is contained in:
1 parent
1298b23844
commit
9c40021318
3 files changed
+8
-23
No files matched your search
@@ -5,13 +5,8 @@ import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
||||
const { time: uptimeDuration, units: uptimeUnits } = getHumanReadableDuration(
|
||||
monitor?.uptimeDuration
|
||||
);
|
||||
|
||||
const { time: lastCheckTime, units: lastCheckUnits } = getHumanReadableDuration(
|
||||
monitor?.lastChecked
|
||||
);
|
||||
const uptimeDuration = getHumanReadableDuration(monitor?.uptimeDuration);
|
||||
const time = getHumanReadableDuration(monitor?.lastChecked);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -22,7 +17,6 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
||||
subHeading={
|
||||
<>
|
||||
{uptimeDuration}
|
||||
<Typography component="span">{uptimeUnits}</Typography>
|
||||
<Typography component="span">{t("ago")}</Typography>
|
||||
</>
|
||||
}
|
||||
@@ -31,8 +25,7 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
||||
heading="last check"
|
||||
subHeading={
|
||||
<>
|
||||
{lastCheckTime}
|
||||
<Typography component="span">{lastCheckUnits}</Typography>
|
||||
{time}
|
||||
<Typography component="span">{t("ago")}</Typography>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -24,30 +24,22 @@ const UptimeStatusBoxes = ({
|
||||
const timeOfLastCheck = monitorStats?.lastCheckTimestamp;
|
||||
const timeSinceLastCheck = Date.now() - timeOfLastCheck;
|
||||
|
||||
const { time: streakTime, units: streakUnits } =
|
||||
getHumanReadableDuration(timeSinceLastFailure);
|
||||
const streakTime = getHumanReadableDuration(timeSinceLastFailure);
|
||||
|
||||
const { time: lastCheckTime, units: lastCheckUnits } =
|
||||
getHumanReadableDuration(timeSinceLastCheck);
|
||||
const lastCheckTime = getHumanReadableDuration(timeSinceLastCheck);
|
||||
return (
|
||||
<StatusBoxes shouldRender={!isLoading}>
|
||||
<StatBox
|
||||
gradient={true}
|
||||
status={determineState(monitor)}
|
||||
heading={"active for"}
|
||||
subHeading={
|
||||
<>
|
||||
{streakTime}
|
||||
<Typography component="span">{streakUnits}</Typography>
|
||||
</>
|
||||
}
|
||||
subHeading={streakTime}
|
||||
/>
|
||||
<StatBox
|
||||
heading="last check"
|
||||
subHeading={
|
||||
<>
|
||||
{lastCheckTime}
|
||||
<Typography component="span">{lastCheckUnits}</Typography>
|
||||
<Typography component="span">{"ago"}</Typography>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ export const getHumanReadableDuration = (ms) => {
|
||||
|
||||
if (result.length === 0) {
|
||||
// fallback for durations < 1s
|
||||
return { time: 0, units: "seconds" };
|
||||
return "0s";
|
||||
}
|
||||
|
||||
return { time: result.join(" "), units: null };
|
||||
return result.join(" ");
|
||||
};
|
||||
|
||||
export const formatDate = (date, customOptions) => {
|
||||
|
||||
Reference in new issue
Block a user