diff --git a/SOPE/NGCards/iCalRecurrenceCalculator.m b/SOPE/NGCards/iCalRecurrenceCalculator.m index eebaa6dfb..d8f0f30bf 100644 --- a/SOPE/NGCards/iCalRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalRecurrenceCalculator.m @@ -161,10 +161,12 @@ static Class yearlyCalcClass = Nil; + (NSArray *) _dates: (NSArray *) dateList withinRange: (NGCalendarDateRange *) limits + startingWithDate: (NGCalendarDateRange *) first { NSMutableArray *newDates; NSEnumerator *dates; NSCalendarDate *currentDate; + NGCalendarDateRange *currentRange; newDates = [NSMutableArray array]; @@ -173,7 +175,10 @@ static Class yearlyCalcClass = Nil; { if ([currentDate isKindOfClass: NSStringClass]) currentDate = [(NSString *) currentDate asCalendarDate]; - if ([limits containsDate: currentDate]) + + currentRange = [NGCalendarDateRange calendarDateRangeWithStartDate: currentDate + endDate: [currentDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: [first duration]]]; + if ([limits doesIntersectWithDateRange: currentRange]) [newDates addObject: currentDate]; } @@ -191,7 +196,7 @@ static Class yearlyCalcClass = Nil; unsigned int count, maxRanges; NSComparisonResult compare; - dates = [[self _dates: exdates withinRange: limits] objectEnumerator]; + dates = [[self _dates: exdates withinRange: limits startingWithDate: first] objectEnumerator]; while ((currentDate = [dates nextObject])) { maxRanges = [ranges count]; diff --git a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m index e47ae3912..0aa339750 100644 --- a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m @@ -191,7 +191,7 @@ for (k = 0; k < [rangesInMonth count] && (repeatCount == 0 || count < repeatCount); k++) { //NSLog(@"*** YEARLY found %@ (count = %i)", [[rangesInMonth objectAtIndex: k] startDate], count); count++; - if ([_r containsDateRange: [rangesInMonth objectAtIndex: k]]) + if ([_r doesIntersectWithDateRange: [rangesInMonth objectAtIndex: k]]) { [ranges addObject: [rangesInMonth objectAtIndex: k]]; //NSLog(@"*** YEARLY adding %@ (count = %i)", [[rangesInMonth objectAtIndex: k] startDate], count); @@ -215,7 +215,7 @@ end = [start addTimeInterval: [firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate: start endDate: end]; - if ([_r containsDateRange: r] && (repeatCount == 0 || count < repeatCount)) + if ([_r doesIntersectWithDateRange: r] && (repeatCount == 0 || count < repeatCount)) { [ranges addObject: r]; count++; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 7d647f949..ac5967655 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1299,17 +1299,13 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir { NSMutableArray *ma; NSDictionary *row; - NSCalendarDate *rangeEndDate; unsigned int count, max; max = [_records count]; ma = [NSMutableArray arrayWithCapacity: max]; - // Adjust the range so it ends at midnight. This is necessary when calculating - // recurrences of all-day events. - rangeEndDate = [[_r endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:1]; _r = [NGCalendarDateRange calendarDateRangeWithStartDate: [_r startDate] - endDate: rangeEndDate]; + endDate: [_r endDate]]; for (count = 0; count < max; count++) {