From af8202e668acb75043c1cfd3112aac4f6e8b0d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Sat, 19 Mar 2022 08:52:17 +0100 Subject: [PATCH] [icalendar] Adding ability to handle events without DTEND (#12482) Signed-off-by: clinique --- .../internal/logic/BiweeklyPresentableCalendar.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 935932328..02d64bbdf 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; } /**