Skip to content

Commit

Permalink
fix: support point-in-time events in the Agenda view (jquense#1246)
Browse files Browse the repository at this point in the history
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}`
```
  • Loading branch information
MatthewHerbst authored and jquense committed Mar 22, 2019
1 parent 7aef31f commit 58c39c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/events.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const now = new Date()

export default [
{
id: 0,
Expand Down Expand Up @@ -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,
},
]
4 changes: 3 additions & 1 deletion src/Agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 58c39c3

Please sign in to comment.