mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-11 13:29:49 +00:00
Fix support for recurrent tasks
This commit is contained in:
@@ -856,16 +856,22 @@ static Class iCalEventK = nil;
|
||||
}
|
||||
[record setObject: dateSecs forKey: @"c_recurrence_id"];
|
||||
|
||||
date = [theCycle endDate];
|
||||
if (theEventTimeZone)
|
||||
date = [record valueForKey: @"c_enddate"];
|
||||
if ([date isNotNull])
|
||||
{
|
||||
secondsOffsetFromGMT = (int) [[theEventTimeZone periodForDate: date] secondsOffsetFromGMT];
|
||||
date = [date dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -secondsOffsetFromGMT];
|
||||
date = [theCycle endDate];
|
||||
if (theEventTimeZone)
|
||||
{
|
||||
secondsOffsetFromGMT = (int) [[theEventTimeZone periodForDate: date] secondsOffsetFromGMT];
|
||||
date = [date dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -secondsOffsetFromGMT];
|
||||
}
|
||||
[date setTimeZone: timeZone];
|
||||
[record setObject: date forKey: @"endDate"];
|
||||
dateSecs = [NSNumber numberWithInt: [date timeIntervalSince1970]];
|
||||
[record setObject: dateSecs forKey: @"c_enddate"];
|
||||
}
|
||||
[date setTimeZone: timeZone];
|
||||
[record setObject: date forKey: @"endDate"];
|
||||
dateSecs = [NSNumber numberWithInt: [date timeIntervalSince1970]];
|
||||
[record setObject: dateSecs forKey: @"c_enddate"];
|
||||
else
|
||||
[record removeObjectForKey: @"endDate"];
|
||||
|
||||
return record;
|
||||
}
|
||||
@@ -967,7 +973,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
toArray: (NSMutableArray *) ma
|
||||
{
|
||||
NGCalendarDateRange *recurrenceIdRange;
|
||||
NSCalendarDate *recurrenceId;
|
||||
NSCalendarDate *recurrenceId, *masterEndDate, *endDate;
|
||||
NSMutableDictionary *newRecord;
|
||||
NGCalendarDateRange *newRecordRange;
|
||||
NSComparisonResult compare;
|
||||
@@ -997,8 +1003,20 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
[recurrenceId setTimeZone: tz];
|
||||
}
|
||||
|
||||
master = [[[component parent] events] objectAtIndex: 0];
|
||||
delta = [[master endDate] timeIntervalSinceDate: [master startDate]];
|
||||
if ([component isKindOfClass: [iCalEvent class]])
|
||||
{
|
||||
master = [[[component parent] events] objectAtIndex: 0];
|
||||
masterEndDate = [master endDate];
|
||||
endDate = [component endDate];
|
||||
}
|
||||
else
|
||||
{
|
||||
master = [[[component parent] todos] objectAtIndex: 0];
|
||||
masterEndDate = [master due];
|
||||
endDate = [component due];
|
||||
}
|
||||
|
||||
delta = [masterEndDate timeIntervalSinceDate: [master startDate]];
|
||||
recurrenceIdRange = [NGCalendarDateRange calendarDateRangeWithStartDate: recurrenceId
|
||||
endDate: [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds: delta]];
|
||||
if ([dateRange doesIntersectWithDateRange: recurrenceIdRange])
|
||||
@@ -1009,8 +1027,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
if (recordIndex > -1)
|
||||
{
|
||||
if ([dateRange containsDate: [component startDate]] ||
|
||||
[dateRange containsDate: [component endDate]])
|
||||
{
|
||||
[dateRange containsDate: endDate])
|
||||
{
|
||||
// We must pass nil to :container here in order to avoid re-entrancy issues.
|
||||
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]];
|
||||
[ma replaceObjectAtIndex: recordIndex withObject: newRecord];
|
||||
|
||||
@@ -84,20 +84,23 @@
|
||||
|
||||
newOccurence = (iCalToDo *) [super newOccurenceWithID: theRecurrenceID];
|
||||
date = [newOccurence recurrenceId];
|
||||
[newOccurence setStartDate: date];
|
||||
|
||||
master = [self component: NO secure: NO];
|
||||
firstDate = [master startDate];
|
||||
|
||||
interval = [[master due]
|
||||
timeIntervalSinceDate: (NSDate *)firstDate];
|
||||
if ([master due])
|
||||
{
|
||||
firstDate = [master startDate];
|
||||
interval = [[master due]
|
||||
timeIntervalSinceDate: (NSDate *)firstDate];
|
||||
|
||||
[newOccurence setStartDate: date];
|
||||
[newOccurence setDue: [date addYear: 0
|
||||
month: 0
|
||||
day: 0
|
||||
hour: 0
|
||||
minute: 0
|
||||
second: interval]];
|
||||
[newOccurence setDue: [date addYear: 0
|
||||
month: 0
|
||||
day: 0
|
||||
hour: 0
|
||||
minute: 0
|
||||
second: interval]];
|
||||
}
|
||||
|
||||
return newOccurence;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
*/
|
||||
- (NSDictionary *) attributesInContext: (WOContext *) context
|
||||
{
|
||||
NSArray *allEvents, *rules;
|
||||
NSArray *allComponents, *rules;
|
||||
NSCalendarDate *untilDate;
|
||||
NSMutableDictionary *data, *repeat;
|
||||
NSString *frequency;
|
||||
@@ -93,8 +93,11 @@
|
||||
{
|
||||
// If the component is an occurrence of a recurrent component,
|
||||
// consider the recurrence rules of the master component.
|
||||
allEvents = [[self parent] events];
|
||||
masterComponent = [allEvents objectAtIndex: 0];
|
||||
if ([self isKindOfClass: [iCalEvent class]])
|
||||
allComponents = [[self parent] events];
|
||||
else
|
||||
allComponents = [[self parent] todos];
|
||||
masterComponent = [allComponents objectAtIndex: 0];
|
||||
rules = [masterComponent recurrenceRules];
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user