From 1ee23a6bec1c35aa721256115b6e8beff9ece7f0 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 12 Sep 2019 10:23:51 -0400 Subject: [PATCH] (fix) make sure we handle events occurring after RRULE's UNTIL date --- NEWS | 1 + SoObjects/Appointments/iCalEvent+SOGo.m | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/NEWS b/NEWS index dbacab051..b99c9df16 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ Bug fixes - [core] honor groups when setting IMAP ACLs - [core] honor "any authenticated user" when setting IMAP ACLs - [core] avoid exceptions for RRULE with no DTSTART + - [core] make sure we handle events occurring after RRULE's UNTIL date 4.0.8 (2019-07-19) ------------------ diff --git a/SoObjects/Appointments/iCalEvent+SOGo.m b/SoObjects/Appointments/iCalEvent+SOGo.m index b2f2deeb5..d297bead8 100644 --- a/SoObjects/Appointments/iCalEvent+SOGo.m +++ b/SoObjects/Appointments/iCalEvent+SOGo.m @@ -175,6 +175,8 @@ if ([self isRecurrent]) { NSCalendarDate *date; + NSArray *events; + iCalEvent *e; date = [self lastPossibleRecurrenceStartDate]; if (date) @@ -183,6 +185,22 @@ /* this could also be *nil*, but in the end it makes the fetchspecs more complex - thus we set it to a "reasonable" distant future */ date = iCalDistantFuture; + + // We have to make sure that we don't have occurrences that are after + // our -lastPossibleRecurrenceStartDate. We do that by walking through + // the events list from the calendar component + events = [[self parent] events]; + + for (i = 0; i < [events count]; i++) + { + e = [events objectAtIndex: i]; + if ([e recurrenceId] && [[e startDate] compare: date] == NSOrderedDescending) + { + date = [e startDate]; + date = [date addTimeInterval: [e durationAsTimeInterval]]; + } + } + [row setObject: [self quickRecordDateAsNumber: date withOffset: 0 forAllDay: NO] forKey: @"c_cycleenddate"];