Skip to content

Commit

Permalink
[icalendar] Adding ability to handle events without DTEND (openhab#12482
Browse files Browse the repository at this point in the history
)

Signed-off-by: clinique <gael@lhopital.org>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
clinique authored and andrasU committed Nov 12, 2022
1 parent fd97dc2 commit f5025bb
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
*/
@NonNullByDefault
class BiweeklyPresentableCalendar extends AbstractPresentableCalendar {
private static final Duration ONE_DAY = Duration.ofDays(1).minusNanos(1);
private final ICalendar usedCalendar;

BiweeklyPresentableCalendar(InputStream streamed) throws IOException, CalendarException {
Expand Down Expand Up @@ -343,11 +344,14 @@ private void classifyEvents(Collection<VEvent> positiveEvents, Collection<VEvent
return Duration.ofMillis(eventDuration.toMillis());
}
final DateStart start = vEvent.getDateStart();
final DateEnd end = vEvent.getDateEnd();
if (start == null || end == null) {
if (start == null) {
return null;
}
return Duration.between(start.getValue().toInstant(), end.getValue().toInstant());
final DateEnd end = vEvent.getDateEnd();
if (end != null) {
return Duration.between(start.getValue().toInstant(), end.getValue().toInstant());
}
return start.getValue().hasTime() ? Duration.ZERO : ONE_DAY;
}

/**
Expand Down

0 comments on commit f5025bb

Please sign in to comment.