From b1b4fa7134c8b9f2ca41baff23f233a6ceb73ef7 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Fri, 6 May 2022 14:37:08 +0100 Subject: [PATCH] (fix) display durations longer than 24hrs (#419) --- src/components/shared/elapsed/elapsed.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/shared/elapsed/elapsed.jsx b/src/components/shared/elapsed/elapsed.jsx index 747a9b69..e77576aa 100644 --- a/src/components/shared/elapsed/elapsed.jsx +++ b/src/components/shared/elapsed/elapsed.jsx @@ -16,14 +16,16 @@ const padTime = (n, withLetters) => n.toString().padStart(withLetters ? 1 : 2, ' const getTimeElapsed = ({ started, finished, withLetters = false }) => { if (!started || !finished) return ''; - const { hours, minutes, seconds } = intervalToDuration({ + const { + days, hours, minutes, seconds, + } = intervalToDuration({ start: new Date(started * 1000), end: new Date(finished * 1000), }); if (withLetters) { - return `${hours ? `${padTime(hours, withLetters)}h` : ''} ${padTime(minutes, withLetters)}m ${padTime(seconds, withLetters)}s`; + return `${days ? `${padTime(days, withLetters)}d` : ''} ${hours ? `${padTime(hours, withLetters)}h` : ''} ${padTime(minutes, withLetters)}m ${padTime(seconds, withLetters)}s`; } - return `${hours ? `${padTime(hours)}:` : ''}${padTime(minutes)}:${padTime(seconds)}`; + return `${days ? `${padTime(days)}` : ''} ${hours ? `${padTime(hours)}:` : ''}${padTime(minutes)}:${padTime(seconds)}`; }; const getTimeElapsedSince = ({ dateSince }) => formatDistanceToNow(