[icalendar] Adding ability to handle events without DTEND (#12482)

Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
Gaël L'hopital 2022-03-19 08:52:17 +01:00 committed by GitHub
parent 963a73ee74
commit af8202e668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -64,6 +64,7 @@ import biweekly.util.com.google.ical.compat.javautil.DateIterator;
*/ */
@NonNullByDefault @NonNullByDefault
class BiweeklyPresentableCalendar extends AbstractPresentableCalendar { class BiweeklyPresentableCalendar extends AbstractPresentableCalendar {
private static final Duration ONE_DAY = Duration.ofDays(1).minusNanos(1);
private final ICalendar usedCalendar; private final ICalendar usedCalendar;
BiweeklyPresentableCalendar(InputStream streamed) throws IOException, CalendarException { BiweeklyPresentableCalendar(InputStream streamed) throws IOException, CalendarException {
@ -343,11 +344,14 @@ class BiweeklyPresentableCalendar extends AbstractPresentableCalendar {
return Duration.ofMillis(eventDuration.toMillis()); return Duration.ofMillis(eventDuration.toMillis());
} }
final DateStart start = vEvent.getDateStart(); final DateStart start = vEvent.getDateStart();
final DateEnd end = vEvent.getDateEnd(); if (start == null) {
if (start == null || end == null) {
return 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;
} }
/** /**