From de0eb4b39463245f29fc396ab621aecb41bba29a Mon Sep 17 00:00:00 2001 From: Dom Needham <=> Date: Sun, 24 Sep 2023 17:18:30 +0100 Subject: [PATCH] Show live text instead of Unix epoch --- src/components/snapshotCard.tsx | 9 ++++++++- .../EventsScreen/components/EventDetails.tsx | 14 ++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/snapshotCard.tsx b/src/components/snapshotCard.tsx index 8516560..0745c8f 100644 --- a/src/components/snapshotCard.tsx +++ b/src/components/snapshotCard.tsx @@ -17,6 +17,13 @@ export const SnapshotCard = ({ const imageWidth = width * 0.97; const imageHeight = imageWidth * 0.75; + // ongoing events have end date of either '1/1/70' or '01/01/1970' + const endDate = + camEvent?.lastEventEnded.startsWith('1/1/70') || + camEvent?.lastEventEnded.startsWith('01/01/1970') + ? 'Current' + : camEvent?.lastEventEnded; + return ( - {camEvent.lastEventEnded} + {endDate} )} diff --git a/src/screens/EventsScreen/components/EventDetails.tsx b/src/screens/EventsScreen/components/EventDetails.tsx index 3664d53..236593a 100644 --- a/src/screens/EventsScreen/components/EventDetails.tsx +++ b/src/screens/EventsScreen/components/EventDetails.tsx @@ -17,6 +17,14 @@ export const EventDetails = ({camEvent}: {camEvent: FrigateEvent}) => { // TODO: format minutes here too. const eventDuration = Math.round(camEvent.end_time - camEvent.start_time); + const endTimeValue = + endDate.getFullYear() === 1970 + ? 'Current' + : endDate.toLocaleDateString() + ' @ ' + endDate.toLocaleTimeString(); + + const durationValue = + eventDuration < 0 ? 'Ongoing' : eventDuration + ' seconds'; + return ( Event Details @@ -30,13 +38,11 @@ export const EventDetails = ({camEvent}: {camEvent: FrigateEvent}) => { End Time - - {endDate.toLocaleDateString() + ' @ ' + endDate.toLocaleTimeString()} - + {endTimeValue} Event Duration - {eventDuration} seconds + {durationValue} Object Label