Skip to content

Commit

Permalink
Show live text instead of Unix epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Needham committed Sep 24, 2023
1 parent f4e192e commit de0eb4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/components/snapshotCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View className="self-center border border-accent dark:border-accent-dark relative rounded-lg">
<Image
Expand All @@ -39,7 +46,7 @@ export const SnapshotCard = ({
{!!camEvent.lastEventEnded && (
<Label>
<BaseText className="text-xs text-mutedForeground dark:text-mutedForeground-dark">
{camEvent.lastEventEnded}
{endDate}
</BaseText>
</Label>
)}
Expand Down
14 changes: 10 additions & 4 deletions src/screens/EventsScreen/components/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<BaseView className="flex-1">
<BaseText className="self-center text-lg mb-1">Event Details</BaseText>
Expand All @@ -30,13 +38,11 @@ export const EventDetails = ({camEvent}: {camEvent: FrigateEvent}) => {
</Row>
<Row>
<BaseText>End Time</BaseText>
<BaseText>
{endDate.toLocaleDateString() + ' @ ' + endDate.toLocaleTimeString()}
</BaseText>
<BaseText>{endTimeValue}</BaseText>
</Row>
<Row>
<BaseText>Event Duration</BaseText>
<BaseText>{eventDuration} seconds</BaseText>
<BaseText>{durationValue}</BaseText>
</Row>
<Row>
<BaseText>Object Label</BaseText>
Expand Down

0 comments on commit de0eb4b

Please sign in to comment.