From 58c39c383ff1f25595605e7484fbdd6017b8f42f Mon Sep 17 00:00:00 2001 From: Matthew Herbst Date: Thu, 21 Mar 2019 19:22:07 -0700 Subject: [PATCH] fix: support point-in-time events in the Agenda view (#1246) Some events may have the same date/time, and are meant to represent point-in-time events, such as deadlines. These are not all day events, but they also should not be represnted as `${startTime} - ${endTime}` since the values will be the same. This will cause an event that is not marked as all day, and where the start and end are equal, to show as: ```js // old `${startTime} - ${endTime}` // new `${startTime}` ``` --- examples/events.js | 8 ++++++++ src/Agenda.js | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/events.js b/examples/events.js index dbf1fa702..5be55c81b 100644 --- a/examples/events.js +++ b/examples/events.js @@ -1,3 +1,5 @@ +const now = new Date() + export default [ { id: 0, @@ -103,4 +105,10 @@ export default [ start: new Date(new Date().setHours(new Date().getHours() - 3)), end: new Date(new Date().setHours(new Date().getHours() + 3)), }, + { + id: 15, + title: 'Point in Time Event', + start: now, + end: now, + }, ] diff --git a/src/Agenda.js b/src/Agenda.js index f185eec92..d5f6da339 100644 --- a/src/Agenda.js +++ b/src/Agenda.js @@ -129,7 +129,9 @@ class Agenda extends React.Component { let start = accessors.start(event) if (!accessors.allDay(event)) { - if (dates.eq(start, end, 'day')) { + if (dates.eq(start, end)) { + label = localizer.format(start, 'agendaTimeFormat') + } else if (dates.eq(start, end, 'day')) { label = localizer.format({ start, end }, 'agendaTimeRangeFormat') } else if (dates.eq(day, start, 'day')) { label = localizer.format(start, 'agendaTimeFormat')