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
maint-2.0.2
Francis Lachapelle 2009-03-16 21:21:43 +00:00
parent 4a13bc463c
commit a8cd172a6b
4 changed files with 78 additions and 30 deletions

View File

@ -1,3 +1,17 @@
2009-03-16 Francis Lachapelle <flachapelle@inverse.ca>
* UI/Scheduler/UIxCalListingActions.m ([UIxCalListingActions
-_fixDates:]): moved corrections for daylight saving time in this
new method.
* SoObjects/Appointments/SOGoAppointmentFolder.m
([SOGoAppointmentFolder
-fixupCycleRecord:_recordcycleRange:_rfirstInstanceCalendarDateRange:_firforViewRange:_viewRange]):
propagate the start date of the cycle so it can be used later to
adjust the timezone.
* ([SOGoAppointmentFolder
-_appendCycleException:firstInstanceCalendarDateRange:fromRow:forRange:toArray:]): idem .
2009-03-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentObject.m

View File

@ -578,20 +578,20 @@ static Class sogoAppointmentFolderKlass = Nil;
return md;
}
- (NSArray *) fixupRecords: (NSArray *) records
- (NSArray *) fixupRecords: (NSArray *) theRecords
{
// TODO: is the result supposed to be sorted by date?
NSMutableArray *ma;
unsigned count, max;
id row; // TODO: what is the type of the record?
if (records)
if (theRecords)
{
max = [records count];
max = [theRecords count];
ma = [NSMutableArray arrayWithCapacity: max];
for (count = 0; count < max; count++)
{
row = [self fixupRecord: [records objectAtIndex: count]];
row = [self fixupRecord: [theRecords objectAtIndex: count]];
if (row)
[ma addObject: row];
}
@ -610,43 +610,31 @@ static Class sogoAppointmentFolderKlass = Nil;
NSMutableDictionary *md;
NSNumber *dateSecs;
id tmp;
signed int daylightOffset;
md = [[_record mutableCopy] autorelease];
daylightOffset = 0;
/* cycle is in _r. We also have to override the c_startdate/c_enddate with the date values of
the reccurence since we use those when displaying events in SOGo Web */
tmp = [_r startDate];
if ([timeZone isDaylightSavingTimeForDate: tmp] != [timeZone isDaylightSavingTimeForDate: [_viewRange startDate]])
// For the event's start/end dates, compute the daylight saving time
// offset with respect to the view period.
daylightOffset = (signed int)[timeZone secondsFromGMTForDate: tmp]
- (signed int)[timeZone secondsFromGMTForDate: [_viewRange startDate]];
tmp = [_r startDate];
[tmp setTimeZone: timeZone];
[md setObject: tmp forKey: @"startDate"];
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
[md setObject: dateSecs forKey: @"c_startdate"];
tmp = [_r endDate];
[tmp setTimeZone: timeZone];
[md setObject: tmp forKey: @"endDate"];
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
[md setObject: dateSecs forKey: @"c_enddate"];
tmp = [_r startDate];
if ([timeZone isDaylightSavingTimeForDate: tmp] != [timeZone isDaylightSavingTimeForDate: [_fir startDate]])
// 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)[timeZone secondsFromGMTForDate: tmp]
- (signed int)[timeZone secondsFromGMTForDate: [_fir startDate]];
else
daylightOffset = 0;
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
[md setObject: dateSecs forKey: @"c_recurrence_id"];
tmp = [_fir startDate];
[md setObject: tmp forKey: @"cycleStartDate"];
return md;
}
@ -657,7 +645,6 @@ static Class sogoAppointmentFolderKlass = Nil;
NSDictionary *currentRecord;
recordIndex = -1;
count = 0;
max = [recordArray count];
while (recordIndex == -1 && count < max)
@ -729,6 +716,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
oldRecord = [ma objectAtIndex: recordIndex];
[newRecord setObject: [oldRecord objectForKey: @"c_recurrence_id"]
forKey: @"c_recurrence_id"];
[newRecord setObject: [fir startDate] forKey: @"cycleStartDate"];
[ma replaceObjectAtIndex: recordIndex withObject: newRecord];
}
else
@ -742,11 +730,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
else
{
newRecord = [self fixupRecord: [component quickRecord]];
newRecordRange = [NGCalendarDateRange calendarDateRangeWithStartDate:
[newRecord objectForKey:
@"startDate"]
endDate: [newRecord objectForKey:
@"endDate"]];
newRecordRange = [NGCalendarDateRange
calendarDateRangeWithStartDate: [newRecord objectForKey: @"startDate"]
endDate: [newRecord objectForKey: @"endDate"]];
if ([dateRange doesIntersectWithDateRange: newRecordRange])
[ma addObject: newRecord];
}

View File

@ -249,7 +249,7 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
recDate = [NSCalendarDate dateWithTimeIntervalSince1970: [recID intValue]];
masterOccurence = [self component: NO secure: NO];
if ([masterOccurence doesOccurOnDate: recDate])
{
newOccurence = [masterOccurence mutableCopy];

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]];
}