Monotone-Parent: 5b4e61e92b3d68b92ea25f1513eb120e502250a1

Monotone-Revision: 1e529d97ad640de07982d342ce216985cba625f7

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-07-20T15:44:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2012-07-20 15:44:25 +00:00
parent 965cd9379e
commit 1476b93a45
5 changed files with 238 additions and 61 deletions

View File

@@ -22,6 +22,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <NGExtensions/NSCalendarDate+misc.h>
@@ -50,11 +51,13 @@
{
NSCalendarDate *startDate, *olEndDate, *untilDate, *exDate;
NSString *monthDay, *month;
NSMutableSet *exceptionDates;
NSArray *realExDates;
iCalRecurrenceRule *rule;
iCalByDayMask *byDayMask;
iCalWeekOccurrence weekOccurrence;
iCalWeekOccurrences dayMaskDays;
NSUInteger count;
NSUInteger count, max;
NSInteger bySetPos;
unsigned char maskValue;
@@ -209,7 +212,12 @@
rp->EndType];
}
/* exception dates */
/* exception dates:
- take all deleted instances
- remove all modified instances from the above set
- add remaining instances, in chronological order
*/
exceptionDates = [NSMutableSet set];
for (count = 0; count < rp->DeletedInstanceCount; count++)
{
exDate
@@ -217,8 +225,23 @@
exDate = [exDate hour: [startDate hourOfDay]
minute: [startDate minuteOfHour]
second: [startDate secondOfMinute]];
[entity addToExceptionDates: exDate];
[exceptionDates addObject: exDate];
}
for (count = 0; count < rp->ModifiedInstanceCount; count++)
{
exDate
= [NSDate dateFromMinutesSince1601: rp->ModifiedInstanceDates[count]];
exDate = [exDate hour: [startDate hourOfDay]
minute: [startDate minuteOfHour]
second: [startDate secondOfMinute]];
[exceptionDates removeObject: exDate];
}
realExDates = [[exceptionDates allObjects]
sortedArrayUsingSelector: @selector (compare:)];
max = [realExDates count];
for (count = 0; count < max; count++)
[entity addToExceptionDates: [realExDates objectAtIndex: count]];
}
@end
@@ -233,11 +256,14 @@
iCalRecurrenceFrequency freq;
iCalByDayMask *byDayMask;
NSString *byMonthDay, *bySetPos;
NSCalendarDate *startDate, *endDate, *untilDate, *beginOfWeek, *minimumDate, *moduloDate, *midnight;
NSCalendarDate *startDate, *endDate, *untilDate, *beginOfWeek, *minimumDate,
*moduloDate, *midnight;
iCalWeekOccurrences *days;
NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence, max;
NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence,
max;
uint32_t nbrMonths, mask;
NSArray *exDates;
NSArray *events;
NSMutableArray *deletedDates, *modifiedDates;
startDate = [event firstRecurrenceStartDate];
[startDate setTimeZone: timeZone];
@@ -394,16 +420,37 @@
}
}
exDates = [[event exceptionDatesWithTimeZone: utcTZ]
sortedArrayUsingFunction: NSDateCompare
context: NULL];
max = [exDates count];
events = [[event parent] events];
max = [events count];
modifiedDates = [NSMutableArray arrayWithCapacity: max];
for (count = 1; count < max; count++)
{
startDate = [[events objectAtIndex: count] recurrenceId];
[modifiedDates addObject: startDate];
}
max = [modifiedDates count];
rp->ModifiedInstanceCount = max;
rp->ModifiedInstanceDates = talloc_array (memCtx, uint32_t, max);
for (count = 0; count < max; count++)
{
startDate = [[modifiedDates objectAtIndex: count]
hour: 0 minute: 0 second: 0];
*(rp->ModifiedInstanceDates + count) = [startDate asMinutesSince1601];
}
deletedDates = [modifiedDates mutableCopy];
[deletedDates autorelease];
[deletedDates
addObjectsFromArray: [event exceptionDatesWithTimeZone: utcTZ]];
[deletedDates sortUsingFunction: NSDateCompare context: NULL];
max = [deletedDates count];
rp->DeletedInstanceCount = max;
rp->DeletedInstanceDates = talloc_array (memCtx, uint32_t, max);
for (count = 0; count < max; count++)
{
startDate = [[exDates objectAtIndex: count] hour: 0 minute: 0 second: 0];
startDate = [[deletedDates objectAtIndex: count]
hour: 0 minute: 0 second: 0];
*(rp->DeletedInstanceDates + count) = [startDate asMinutesSince1601];
}
}