mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-29 08:49:27 +00:00
Fixed daylight saving time support for the web interface.
Monotone-Parent: 34b0098e2e34111ae63e0f056fceabfd7cb1362e Monotone-Revision: 3e11a03b205eab5434bea8b8a0f1a401eff54568 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2008-12-30T14:47:58 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
@@ -607,27 +608,48 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
|
||||
- (NSMutableDictionary *) fixupCycleRecord: (NSDictionary *) _record
|
||||
cycleRange: (NGCalendarDateRange *) _r
|
||||
firstInstanceCalendarDateRange: (NGCalendarDateRange *) _fir
|
||||
forViewRange: (NGCalendarDateRange *) _viewRange
|
||||
{
|
||||
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 setTimeZone: timeZone];
|
||||
[md setObject: tmp forKey: @"startDate"];
|
||||
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
|
||||
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
|
||||
[md setObject: dateSecs forKey: @"c_startdate"];
|
||||
[md setObject: dateSecs forKey: @"c_recurrence_id"];
|
||||
|
||||
tmp = [_r endDate];
|
||||
[tmp setTimeZone: timeZone];
|
||||
[md setObject: tmp forKey: @"endDate"];
|
||||
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
|
||||
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
|
||||
[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];
|
||||
[md setObject: dateSecs forKey: @"c_recurrence_id"];
|
||||
|
||||
return md;
|
||||
}
|
||||
@@ -672,6 +694,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
}
|
||||
|
||||
- (void) _appendCycleException: (iCalRepeatableEntityObject *) component
|
||||
firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
fromRow: (NSDictionary *) row
|
||||
forRange: (NGCalendarDateRange *) dateRange
|
||||
toArray: (NSMutableArray *) ma
|
||||
@@ -681,9 +704,20 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
NSDictionary *oldRecord;
|
||||
NGCalendarDateRange *newRecordRange;
|
||||
int recordIndex;
|
||||
signed int daylightOffset;
|
||||
|
||||
newRecord = nil;
|
||||
recurrenceId = [component recurrenceId];
|
||||
|
||||
if ([timeZone isDaylightSavingTimeForDate: recurrenceId] != [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: [fir startDate]]
|
||||
- (signed int)[timeZone secondsFromGMTForDate: recurrenceId];
|
||||
recurrenceId = [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
||||
}
|
||||
|
||||
if ([dateRange containsDate: recurrenceId])
|
||||
{
|
||||
recordIndex = [self _indexOfRecordMatchingDate: recurrenceId
|
||||
@@ -726,6 +760,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
}
|
||||
|
||||
- (void) _appendCycleExceptionsFromRow: (NSDictionary *) row
|
||||
firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
forRange: (NGCalendarDateRange *) dateRange
|
||||
toArray: (NSMutableArray *) ma
|
||||
{
|
||||
@@ -743,6 +778,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
max = [components count];
|
||||
for (count = 1; count < max; count++)
|
||||
[self _appendCycleException: [components objectAtIndex: count]
|
||||
firstInstanceCalendarDateRange: fir
|
||||
fromRow: row
|
||||
forRange: dateRange
|
||||
toArray: ma];
|
||||
@@ -802,12 +838,16 @@ static Class sogoAppointmentFolderKlass = Nil;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
rRange = [ranges objectAtIndex: i];
|
||||
fixedRow = [self fixupCycleRecord: row cycleRange: rRange];
|
||||
fixedRow = [self fixupCycleRecord: row
|
||||
cycleRange: rRange
|
||||
firstInstanceCalendarDateRange: fir
|
||||
forViewRange: _r];
|
||||
if (fixedRow)
|
||||
[recordArray addObject: fixedRow];
|
||||
}
|
||||
|
||||
[self _appendCycleExceptionsFromRow: row
|
||||
firstInstanceCalendarDateRange: fir
|
||||
forRange: _r
|
||||
toArray: recordArray];
|
||||
|
||||
|
||||
@@ -230,6 +230,7 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
|
||||
|
||||
recDate = [NSCalendarDate dateWithTimeIntervalSince1970: [recID intValue]];
|
||||
masterOccurence = [self component: NO secure: NO];
|
||||
|
||||
if ([masterOccurence doesOccurOnDate: recDate])
|
||||
{
|
||||
newOccurence = [masterOccurence mutableCopy];
|
||||
|
||||
@@ -115,13 +115,7 @@
|
||||
|
||||
doesOccur = [self isRecurrent];
|
||||
if (doesOccur)
|
||||
{
|
||||
// tz = [occurenceDate timeZone];
|
||||
// if ([tz isDaylightSavingTimeForDate: occurenceDate] != [tz isDaylightSavingTimeForDate: [self startDate]]) {
|
||||
// daylightOffset = [tz secondsFromGMTForDate: occurenceDate] - [tz secondsFromGMTForDate: [self startDate]];
|
||||
// occurenceDate = [occurenceDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: daylightOffset];
|
||||
// }
|
||||
|
||||
{
|
||||
endDate = [occurenceDate addTimeInterval: [self occurenceInterval]];
|
||||
checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: occurenceDate
|
||||
endDate: endDate];
|
||||
|
||||
Reference in New Issue
Block a user