From: Gaƫl L'hopital Date: Sat, 19 Mar 2022 07:52:17 +0000 (+0100) Subject: [icalendar] Adding ability to handle events without DTEND (#12482) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=af8202e668acb75043c1cfd3112aac4f6e8b0d02;p=openhab-addons.git [icalendar] Adding ability to handle events without DTEND (#12482) Signed-off-by: clinique --- diff --git a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendar.java b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendar.java index 935932328b..02d64bbdf5 100644 --- a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendar.java +++ b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendar.java @@ -64,6 +64,7 @@ import biweekly.util.com.google.ical.compat.javautil.DateIterator; */ @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 { @@ -343,11 +344,14 @@ class BiweeklyPresentableCalendar extends AbstractPresentableCalendar { 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; } /**