From ab94153bfc56c7e08a47009edb2f08c1bef69608 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 14 Jan 2011 19:07:43 +0000 Subject: [PATCH] Monotone-Parent: b6726f7b87c51426fc4fa2e3ed33d20cb47a89e0 Monotone-Revision: f638868d7db65b1617476f06e76394a24bca8310 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-01-14T19:07:43 Monotone-Branch: ca.inverse.sogo --- SOPE/NGCards/iCalRepeatableEntityObject.m | 23 +++++++++------- .../Appointments/SOGoAppointmentFolder.m | 27 +++++++++---------- .../iCalRepeatableEntityObject+SOGo.m | 5 +++- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/SOPE/NGCards/iCalRepeatableEntityObject.m b/SOPE/NGCards/iCalRepeatableEntityObject.m index 3094474db..f24f4ad88 100644 --- a/SOPE/NGCards/iCalRepeatableEntityObject.m +++ b/SOPE/NGCards/iCalRepeatableEntityObject.m @@ -178,19 +178,24 @@ NSString *dateString; unsigned i; - dates = [NSMutableArray array]; - dateList = [[self childrenWithTag: @"exdate"] objectEnumerator]; - - while ((dateString = [dateList nextObject])) + if (theTimeZone) { - exDates = [(iCalDateTime*) dateString values]; - for (i = 0; i < [exDates count]; i++) + dates = [NSMutableArray array]; + dateList = [[self childrenWithTag: @"exdate"] objectEnumerator]; + + while ((dateString = [dateList nextObject])) { - dateString = [exDates objectAtIndex: i]; - exDate = [theTimeZone computedDateForString: dateString]; - [dates addObject: exDate]; + exDates = [(iCalDateTime*) dateString values]; + for (i = 0; i < [exDates count]; i++) + { + dateString = [exDates objectAtIndex: i]; + exDate = [theTimeZone computedDateForString: dateString]; + [dates addObject: exDate]; + } } } + else + dates = [self exceptionDates]; return dates; } diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 4e52dba15..86bd4fff5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -835,7 +835,6 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir NSMutableDictionary *row, *fixedRow; NSMutableArray *records; NSDictionary *cycleinfo; - NSCalendarDate *startDate, *endDate; NGCalendarDateRange *firstRange, *oneRange; NSArray *rules, *exRules, *exDates, *ranges; NSArray *elements, *components; @@ -864,14 +863,14 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir theRecord]; return; } + rules = [cycleinfo objectForKey: @"rules"]; + exRules = [cycleinfo objectForKey: @"exRules"]; + exDates = [cycleinfo objectForKey: @"exDates"]; row = [self fixupRecord: theRecord]; [row removeObjectForKey: @"c_cycleinfo"]; [row setObject: sharedYes forKey: @"isRecurrentEvent"]; - startDate = [row objectForKey: @"startDate"]; - endDate = [row objectForKey: @"endDate"]; - content = [theRecord objectForKey: @"c_content"]; if ([content length]) { @@ -886,20 +885,20 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir firstStartDate = (iCalDateTime*)[component uniqueChildWithTag: @"dtstart"]; firstEndDate = (iCalDateTime*)[component uniqueChildWithTag: @"dtend"]; eventTimeZone = [firstStartDate timeZone]; - startDate = [eventTimeZone computedDateForDate: startDate]; firstRange = [NGCalendarDateRange calendarDateRangeWithStartDate: [[[firstStartDate values] lastObject] asCalendarDate] endDate: [[[firstEndDate values] lastObject] asCalendarDate]]; - // Adjust the range to check with respect to the event timezone (extracted from the start date) - checkStartDate = [eventTimeZone computedDateForDate: [theRange startDate]]; - checkEndDate = [eventTimeZone computedDateForDate: [theRange endDate]]; - theRange = [NGCalendarDateRange calendarDateRangeWithStartDate: checkStartDate - endDate: checkEndDate]; - + if (eventTimeZone) + { + // Adjust the range to check with respect to the event timezone (extracted from the start date) + checkStartDate = [eventTimeZone computedDateForDate: [theRange startDate]]; + checkEndDate = [eventTimeZone computedDateForDate: [theRange endDate]]; + theRange = [NGCalendarDateRange calendarDateRangeWithStartDate: checkStartDate + endDate: checkEndDate]; + exDates = [eventTimeZone computedDatesForStrings: exDates]; + } + // Calculate the occurrences for the given range - rules = [cycleinfo objectForKey: @"rules"]; - exRules = [cycleinfo objectForKey: @"exRules"]; - exDates = [eventTimeZone computedDatesForStrings: [cycleinfo objectForKey: @"exDates"]]; ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange: theRange firstInstanceCalendarDateRange: firstRange recurrenceRules: rules diff --git a/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m b/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m index 6677ca652..c03ee9956 100644 --- a/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m +++ b/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m @@ -130,7 +130,10 @@ // Set the range to check with respect to the event timezone (extracted from the start date) firstStartDate = (iCalDateTime *)[self uniqueChildWithTag: @"dtstart"]; eventTimeZone = [firstStartDate timeZone]; - startDate = [eventTimeZone computedDateForDate: theOccurenceDate]; + if (eventTimeZone) + startDate = [eventTimeZone computedDateForDate: theOccurenceDate]; + else + startDate = theOccurenceDate; endDate = [startDate addTimeInterval: [self occurenceInterval]]; checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: startDate endDate: endDate];