Skip to content

Commit 781392d

Browse files
authored
Merge pull request #1151 from StoDevX/hawkrives-patch-2
clean up calendar times
2 parents a3d0dbe + b9a5038 commit 781392d

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

source/views/calendar/event-row.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default function EventRow({
4141
}) {
4242
const title = fastGetTrimmedText(event.summary)
4343

44+
const location = event.location && event.location.trim().length
45+
? <Detail style={styles.detail}>{event.location}</Detail>
46+
: null
47+
4448
return (
4549
<ListRow
4650
contentContainerStyle={styles.row}
@@ -53,9 +57,14 @@ export default function EventRow({
5357

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

56-
<Column flex={1} paddingTop={2} paddingBottom={3}>
60+
<Column
61+
flex={1}
62+
paddingTop={2}
63+
paddingBottom={3}
64+
justifyContent="space-between"
65+
>
5766
<Title style={styles.title}>{title}</Title>
58-
<Detail style={styles.detail}>{event.location}</Detail>
67+
{location}
5968
</Column>
6069
</Row>
6170
</ListRow>
@@ -79,21 +88,33 @@ function CalendarTimes({event, style}: {event: EventType, style: any}) {
7988
)
8089
}
8190

91+
let startTimeFormatted = event.startTime.format('h:mm A')
92+
let endTimeFormatted = event.endTime.format('h:mm A')
93+
let midnightTime = '12:00 AM'
94+
8295
let start, end
8396
if (event.isOngoing) {
8497
start = event.startTime.format('MMM. D')
8598
end = event.endTime.format('MMM. D')
8699
} else if (multiDay) {
87-
start = event.startTime.format('h:mm A')
88-
end = `to ${event.endTime.format('MMM. D h:mm A')}`
100+
// 12:00 PM to Jun. 25 3:00pm
101+
// Midnight to Jun. 25 <-- assuming the end time is also midnight
102+
start = startTimeFormatted
103+
const endFormat = endTimeFormatted === midnightTime
104+
? 'MMM. D'
105+
: 'MMM. D h:mm A'
106+
end = `to ${event.endTime.format(endFormat)}`
89107
} else if (sillyZeroLength) {
90-
start = event.startTime.format('h:mm A')
108+
start = startTimeFormatted
91109
end = 'until ???'
92110
} else {
93-
start = event.startTime.format('h:mm A')
94-
end = event.endTime.format('h:mm A')
111+
start = startTimeFormatted
112+
end = endTimeFormatted
95113
}
96114

115+
start = start === midnightTime ? 'Midnight' : start
116+
end = end === midnightTime ? 'Midnight' : end
117+
97118
return (
98119
<Column style={style}>
99120
<Text style={[styles.time, styles.start]}>{start}</Text>

0 commit comments

Comments
 (0)