mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-18 09:48:12 +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:
1 parent
85a9589d65
commit
eccf8870d4
4 files changed
+98
-20
No files matched your search
@@ -23,6 +23,7 @@
|
|||||||
#import <Foundation/NSCalendarDate.h>
|
#import <Foundation/NSCalendarDate.h>
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
|
#import <Foundation/NSTimeZone.h>
|
||||||
#import <Foundation/NSURL.h>
|
#import <Foundation/NSURL.h>
|
||||||
#import <Foundation/NSUserDefaults.h>
|
#import <Foundation/NSUserDefaults.h>
|
||||||
#import <Foundation/NSValue.h>
|
#import <Foundation/NSValue.h>
|
||||||
@@ -607,27 +608,48 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
|
|
||||||
- (NSMutableDictionary *) fixupCycleRecord: (NSDictionary *) _record
|
- (NSMutableDictionary *) fixupCycleRecord: (NSDictionary *) _record
|
||||||
cycleRange: (NGCalendarDateRange *) _r
|
cycleRange: (NGCalendarDateRange *) _r
|
||||||
|
firstInstanceCalendarDateRange: (NGCalendarDateRange *) _fir
|
||||||
|
forViewRange: (NGCalendarDateRange *) _viewRange
|
||||||
{
|
{
|
||||||
NSMutableDictionary *md;
|
NSMutableDictionary *md;
|
||||||
NSNumber *dateSecs;
|
NSNumber *dateSecs;
|
||||||
id tmp;
|
id tmp;
|
||||||
|
signed int daylightOffset;
|
||||||
|
|
||||||
md = [[_record mutableCopy] autorelease];
|
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
|
/* 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 */
|
the reccurence since we use those when displaying events in SOGo Web */
|
||||||
|
|
||||||
tmp = [_r startDate];
|
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];
|
[tmp setTimeZone: timeZone];
|
||||||
[md setObject: tmp forKey: @"startDate"];
|
[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_startdate"];
|
||||||
[md setObject: dateSecs forKey: @"c_recurrence_id"];
|
|
||||||
|
|
||||||
tmp = [_r endDate];
|
tmp = [_r endDate];
|
||||||
[tmp setTimeZone: timeZone];
|
[tmp setTimeZone: timeZone];
|
||||||
[md setObject: tmp forKey: @"endDate"];
|
[md setObject: tmp forKey: @"endDate"];
|
||||||
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970]];
|
dateSecs = [NSNumber numberWithInt: [tmp timeIntervalSince1970] + daylightOffset];
|
||||||
[md setObject: dateSecs forKey: @"c_enddate"];
|
[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;
|
return md;
|
||||||
}
|
}
|
||||||
@@ -672,6 +694,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) _appendCycleException: (iCalRepeatableEntityObject *) component
|
- (void) _appendCycleException: (iCalRepeatableEntityObject *) component
|
||||||
|
firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||||
fromRow: (NSDictionary *) row
|
fromRow: (NSDictionary *) row
|
||||||
forRange: (NGCalendarDateRange *) dateRange
|
forRange: (NGCalendarDateRange *) dateRange
|
||||||
toArray: (NSMutableArray *) ma
|
toArray: (NSMutableArray *) ma
|
||||||
@@ -681,9 +704,20 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
NSDictionary *oldRecord;
|
NSDictionary *oldRecord;
|
||||||
NGCalendarDateRange *newRecordRange;
|
NGCalendarDateRange *newRecordRange;
|
||||||
int recordIndex;
|
int recordIndex;
|
||||||
|
signed int daylightOffset;
|
||||||
|
|
||||||
newRecord = nil;
|
newRecord = nil;
|
||||||
recurrenceId = [component recurrenceId];
|
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])
|
if ([dateRange containsDate: recurrenceId])
|
||||||
{
|
{
|
||||||
recordIndex = [self _indexOfRecordMatchingDate: recurrenceId
|
recordIndex = [self _indexOfRecordMatchingDate: recurrenceId
|
||||||
@@ -726,6 +760,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) _appendCycleExceptionsFromRow: (NSDictionary *) row
|
- (void) _appendCycleExceptionsFromRow: (NSDictionary *) row
|
||||||
|
firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||||
forRange: (NGCalendarDateRange *) dateRange
|
forRange: (NGCalendarDateRange *) dateRange
|
||||||
toArray: (NSMutableArray *) ma
|
toArray: (NSMutableArray *) ma
|
||||||
{
|
{
|
||||||
@@ -743,6 +778,7 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
max = [components count];
|
max = [components count];
|
||||||
for (count = 1; count < max; count++)
|
for (count = 1; count < max; count++)
|
||||||
[self _appendCycleException: [components objectAtIndex: count]
|
[self _appendCycleException: [components objectAtIndex: count]
|
||||||
|
firstInstanceCalendarDateRange: fir
|
||||||
fromRow: row
|
fromRow: row
|
||||||
forRange: dateRange
|
forRange: dateRange
|
||||||
toArray: ma];
|
toArray: ma];
|
||||||
@@ -802,12 +838,16 @@ static Class sogoAppointmentFolderKlass = Nil;
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
rRange = [ranges objectAtIndex: i];
|
rRange = [ranges objectAtIndex: i];
|
||||||
fixedRow = [self fixupCycleRecord: row cycleRange: rRange];
|
fixedRow = [self fixupCycleRecord: row
|
||||||
|
cycleRange: rRange
|
||||||
|
firstInstanceCalendarDateRange: fir
|
||||||
|
forViewRange: _r];
|
||||||
if (fixedRow)
|
if (fixedRow)
|
||||||
[recordArray addObject: fixedRow];
|
[recordArray addObject: fixedRow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self _appendCycleExceptionsFromRow: row
|
[self _appendCycleExceptionsFromRow: row
|
||||||
|
firstInstanceCalendarDateRange: fir
|
||||||
forRange: _r
|
forRange: _r
|
||||||
toArray: recordArray];
|
toArray: recordArray];
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
|
|||||||
|
|
||||||
recDate = [NSCalendarDate dateWithTimeIntervalSince1970: [recID intValue]];
|
recDate = [NSCalendarDate dateWithTimeIntervalSince1970: [recID intValue]];
|
||||||
masterOccurence = [self component: NO secure: NO];
|
masterOccurence = [self component: NO secure: NO];
|
||||||
|
|
||||||
if ([masterOccurence doesOccurOnDate: recDate])
|
if ([masterOccurence doesOccurOnDate: recDate])
|
||||||
{
|
{
|
||||||
newOccurence = [masterOccurence mutableCopy];
|
newOccurence = [masterOccurence mutableCopy];
|
||||||
|
|||||||
@@ -115,13 +115,7 @@
|
|||||||
|
|
||||||
doesOccur = [self isRecurrent];
|
doesOccur = [self isRecurrent];
|
||||||
if (doesOccur)
|
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]];
|
endDate = [occurenceDate addTimeInterval: [self occurenceInterval]];
|
||||||
checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: occurenceDate
|
checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: occurenceDate
|
||||||
endDate: endDate];
|
endDate: endDate];
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
|
#import <Foundation/NSTimeZone.h>
|
||||||
|
|
||||||
#import <NGObjWeb/SoObject.h>
|
#import <NGObjWeb/SoObject.h>
|
||||||
#import <NGObjWeb/SoPermissions.h>
|
#import <NGObjWeb/SoPermissions.h>
|
||||||
@@ -224,12 +225,35 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSCalendarDate *firstDate;
|
||||||
|
NSTimeZone *timeZone;
|
||||||
|
iCalEvent *master;
|
||||||
|
signed int daylightOffset;
|
||||||
|
|
||||||
startDate = [event startDate];
|
startDate = [event startDate];
|
||||||
|
daylightOffset = 0;
|
||||||
|
|
||||||
|
if ([co isNew] && [co isKindOfClass: [SOGoAppointmentOccurence class]])
|
||||||
|
{
|
||||||
|
// We are creating a new exception in a recurrent event -- compute the daylight
|
||||||
|
// saving time with respect to the first occurrence of the recurrent event.
|
||||||
|
master = (iCalEvent*)[[event parent] firstChildWithTag: @"vevent"];
|
||||||
|
firstDate = [master startDate];
|
||||||
|
timeZone = [[context activeUser] timeZone];
|
||||||
|
|
||||||
|
if ([timeZone isDaylightSavingTimeForDate: startDate] != [timeZone isDaylightSavingTimeForDate: firstDate])
|
||||||
|
{
|
||||||
|
daylightOffset = (signed int)[timeZone secondsFromGMTForDate: firstDate]
|
||||||
|
- (signed int)[timeZone secondsFromGMTForDate: startDate];
|
||||||
|
startDate = [startDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isAllDay = [event isAllDay];
|
isAllDay = [event isAllDay];
|
||||||
if (isAllDay)
|
if (isAllDay)
|
||||||
endDate = [[event endDate] dateByAddingYears: 0 months: 0 days: -1];
|
endDate = [[event endDate] dateByAddingYears: 0 months: 0 days: -1];
|
||||||
else
|
else
|
||||||
endDate = [event endDate];
|
endDate = [[event endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
||||||
isTransparent = ![event isOpaque];
|
isTransparent = ![event isOpaque];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,21 +383,41 @@
|
|||||||
{
|
{
|
||||||
WOResponse *result;
|
WOResponse *result;
|
||||||
NSDictionary *data;
|
NSDictionary *data;
|
||||||
|
NSCalendarDate *firstDate, *eventDate;
|
||||||
|
NSTimeZone *timeZone;
|
||||||
SOGoDateFormatter *dateFormatter;
|
SOGoDateFormatter *dateFormatter;
|
||||||
SOGoUser *user;
|
SOGoUser *user;
|
||||||
NSCalendarDate *startDate;
|
SOGoCalendarComponent *co;
|
||||||
|
iCalEvent *master;
|
||||||
|
signed int daylightOffset;
|
||||||
|
|
||||||
|
[self event];
|
||||||
|
|
||||||
result = [context response];
|
result = [context response];
|
||||||
user = [context activeUser];
|
user = [context activeUser];
|
||||||
|
timeZone = [user timeZone];
|
||||||
dateFormatter = [user dateFormatterInContext: context];
|
dateFormatter = [user dateFormatterInContext: context];
|
||||||
|
eventDate = [event startDate];
|
||||||
|
[eventDate setTimeZone: timeZone];
|
||||||
|
co = [self clientObject];
|
||||||
|
|
||||||
|
if ([co isNew] && [co isKindOfClass: [SOGoAppointmentOccurence class]])
|
||||||
|
{
|
||||||
|
// This is a new exception in a recurrent event -- compute the daylight
|
||||||
|
// saving time with respect to the first occurrence of the recurrent event.
|
||||||
|
master = (iCalEvent*)[[event parent] firstChildWithTag: @"vevent"];
|
||||||
|
firstDate = [master startDate];
|
||||||
|
|
||||||
[self event];
|
if ([timeZone isDaylightSavingTimeForDate: eventDate] != [timeZone isDaylightSavingTimeForDate: firstDate])
|
||||||
startDate = [[event startDate] copy];
|
{
|
||||||
[startDate setTimeZone: [user timeZone]];
|
daylightOffset = (signed int)[timeZone secondsFromGMTForDate: firstDate]
|
||||||
|
- (signed int)[timeZone secondsFromGMTForDate: eventDate];
|
||||||
|
eventDate = [eventDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
||||||
|
}
|
||||||
|
}
|
||||||
data = [NSDictionary dictionaryWithObjectsAndKeys:
|
data = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[dateFormatter formattedDate: startDate], @"startDate",
|
[dateFormatter formattedDate: eventDate], @"startDate",
|
||||||
[dateFormatter formattedTime: startDate], @"startTime",
|
[dateFormatter formattedTime: eventDate], @"startTime",
|
||||||
([event hasRecurrenceRules]? @"1": @"0"), @"isReccurent",
|
([event hasRecurrenceRules]? @"1": @"0"), @"isReccurent",
|
||||||
([event isAllDay] ? @"1": @"0"), @"isAllDay",
|
([event isAllDay] ? @"1": @"0"), @"isAllDay",
|
||||||
[event summary], @"summary",
|
[event summary], @"summary",
|
||||||
@@ -382,7 +426,6 @@
|
|||||||
nil];
|
nil];
|
||||||
|
|
||||||
[result appendContentString: [data jsonRepresentation]];
|
[result appendContentString: [data jsonRepresentation]];
|
||||||
[startDate release];
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user