Skip to content

Commit

Permalink
(fix) fixed handling of exdates and proper intersection for fbinfo (f…
Browse files Browse the repository at this point in the history
…ixes #4051)
  • Loading branch information
extrafu committed Mar 3, 2017
1 parent 0627c2f commit 588ec2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 7 additions & 2 deletions SOPE/NGCards/iCalRecurrenceCalculator.m
Expand Up @@ -160,10 +160,12 @@ + (void) _removeExceptionsFromRanges: (NSMutableArray *) ranges

+ (NSArray *) _dates: (NSArray *) dateList
withinRange: (NGCalendarDateRange *) limits
startingWithDate: (NGCalendarDateRange *) first
{
NSMutableArray *newDates;
NSEnumerator *dates;
NSCalendarDate *currentDate;
NGCalendarDateRange *currentRange;

newDates = [NSMutableArray array];

Expand All @@ -172,7 +174,10 @@ + (NSArray *) _dates: (NSArray *) dateList
{
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];
}

Expand All @@ -190,7 +195,7 @@ + (void) _removeExceptionDatesFromRanges: (NSMutableArray *) ranges
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];
Expand Down
4 changes: 2 additions & 2 deletions SOPE/NGCards/iCalYearlyRecurrenceCalculator.m
Expand Up @@ -191,7 +191,7 @@ @implementation iCalYearlyRecurrenceCalculator
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);
Expand All @@ -215,7 +215,7 @@ @implementation iCalYearlyRecurrenceCalculator
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++;
Expand Down
6 changes: 1 addition & 5 deletions SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -1285,17 +1285,13 @@ - (NSArray *) _flattenCycleRecords: (NSArray *) _records
{
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++)
{
Expand Down

0 comments on commit 588ec2b

Please sign in to comment.