See ChangeLog

Monotone-Parent: ccbc02cbbccf4d53a21e791dc3aa318d85eb34a9
Monotone-Revision: e32cb5a49f7eb94c778c878808a9abcb69576a80

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-03-16T21:21:43
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2009-03-16 21:21:43 +00:00
parent 4a13bc463c
commit a8cd172a6b
4 changed files with 78 additions and 30 deletions
+48
View File
@@ -34,6 +34,7 @@
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import <NGCards/iCalPerson.h>
#import <NGExtensions/NGCalendarDateRange.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoDateFormatter.h>
@@ -247,6 +248,50 @@ static NSArray *tasksFields = nil;
forKey: @"c_title"];
}
- (void) _fixDates: (NSMutableDictionary *) aRecord
{
NSCalendarDate *aDate, *aStartDate;
NSNumber *aDateValue;
NSString *aDateField;
signed int daylightOffset;
unsigned int count;
static NSString *fields[] = { @"startDate", @"c_startdate",
@"endDate", @"c_enddate" };
for (count = 0; count < 2; count++)
{
aDateField = fields[count * 2];
aDate = [aRecord objectForKey: aDateField];
if ([userTimeZone isDaylightSavingTimeForDate: aDate] !=
[userTimeZone isDaylightSavingTimeForDate: startDate])
{
daylightOffset = (signed int)[userTimeZone secondsFromGMTForDate: aDate]
- (signed int)[userTimeZone secondsFromGMTForDate: startDate];
aDate = [aDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
[aRecord setObject: aDate forKey: aDateField];
aDateValue = [NSNumber numberWithInt: [aDate timeIntervalSince1970]];
[aRecord setObject: aDateValue forKey: fields[count * 2 + 1]];
}
}
aDateValue = [aRecord objectForKey: @"c_recurrence_id"];
aDate = [aRecord objectForKey: @"cycleStartDate"];
aStartDate = [aRecord objectForKey: @"startDate"];
if (aDateValue && aDate)
{
if ([userTimeZone isDaylightSavingTimeForDate: aStartDate] !=
[userTimeZone isDaylightSavingTimeForDate: aDate])
{
// For the event's recurrence id, compute the daylight saving time
// offset with respect to the first occurrence of the recurring event.
daylightOffset = (signed int)[userTimeZone secondsFromGMTForDate: aStartDate]
- (signed int)[userTimeZone secondsFromGMTForDate: aDate];
aDateValue = [NSNumber numberWithInt: [aDateValue intValue] + daylightOffset];
[aRecord setObject: aDateValue forKey: @"c_recurrence_id"];
}
}
}
- (NSArray *) _fetchFields: (NSArray *) fields
forComponentOfType: (NSString *) component
{
@@ -282,6 +327,9 @@ static NSArray *tasksFields = nil;
forKey: @"c_owner"];
if (![[newInfo objectForKey: @"c_title"] length])
[self _fixComponentTitle: newInfo withType: component];
// Possible improvement: only call _fixDates if event is recurrent
// or the view range span a daylight saving time change
[self _fixDates: newInfo];
[infos addObject: [newInfo objectsForKeys: fields
notFoundMarker: marker]];
}