Skip to content

Commit 1b63090

Browse files
authored
clean up calendar times
1 parent 51ffc58 commit 1b63090

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

source/views/calendar/event-row.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export default function EventRow({
4040
onPress: () => any,
4141
}) {
4242
const title = fastGetTrimmedText(event.summary)
43+
44+
const location = event.location && event.location.trim().length
45+
? <Detail style={styles.detail}>{event.location}</Detail>
46+
: null
4347

4448
return (
4549
<ListRow
@@ -53,9 +57,9 @@ export default function EventRow({
5357

5458
<Bar style={styles.bar} />
5559

56-
<Column flex={1} paddingTop={2} paddingBottom={3}>
60+
<Column flex={1} paddingTop={2} paddingBottom={3} justifyContent="space-between">
5761
<Title style={styles.title}>{title}</Title>
58-
<Detail style={styles.detail}>{event.location}</Detail>
62+
{location}
5963
</Column>
6064
</Row>
6165
</ListRow>
@@ -78,21 +82,31 @@ function CalendarTimes({event, style}: {event: EventType, style: any}) {
7882
</Column>
7983
)
8084
}
85+
86+
let startTime = event.startTime.format('h:mm A')
87+
let endTime = event.endTime.format('h:mm A')
88+
let midnightTime = '12:00 AM'
8189

8290
let start, end
8391
if (event.isOngoing) {
8492
start = event.startTime.format('MMM. D')
8593
end = event.endTime.format('MMM. D')
8694
} else if (multiDay) {
95+
// 12:00 PM to Jun. 25 3:00pm
96+
// Midnight to Jun. 25 <-- assuming the end time is also midnight
8797
start = event.startTime.format('h:mm A')
88-
end = `to ${event.endTime.format('MMM. D h:mm A')}`
98+
const endFormat = endTime === midnightTime ? 'MMM. D' : 'MMM. D h:mm A''
99+
end = `to ${event.endTime.format(endFormat)}`
89100
} else if (sillyZeroLength) {
90101
start = event.startTime.format('h:mm A')
91102
end = 'until ???'
92103
} else {
93104
start = event.startTime.format('h:mm A')
94105
end = event.endTime.format('h:mm A')
95106
}
107+
108+
start = start === midnightTime ? 'Midnight' : start
109+
end = end === midnightTime ? 'Midnight' : end
96110

97111
return (
98112
<Column style={style}>

0 commit comments

Comments
 (0)