diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index e35925a4b..e19941653 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -22,6 +22,7 @@ import CalendarIcon from '../icons/Calendar'; import Calendar from '../components/Calendar'; import Button from '../components/Button'; import Dialog from '../components/Dialog'; +import { fromUnixTime, intervalToDuration, formatDuration } from 'date-fns'; const API_LIMIT = 25; @@ -37,6 +38,16 @@ const monthsAgo = (num) => { return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() / 1000; }; +const clipDuration = (start_time, end_time) => { + const start = fromUnixTime(start_time); + const end = fromUnixTime(end_time); + let duration = 'In Progress'; + if (end_time) { + duration = formatDuration(intervalToDuration({ start, end })); + } + return duration; +} + export default function Events({ path, ...props }) { const apiHost = useApiHost(); const [searchParams, setSearchParams] = useState({ @@ -459,7 +470,7 @@ export default function Events({ path, ...props }) {