From 62433faf3515f51cb7015b9611f80c88c8b65a53 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 6 Jan 2010 19:21:15 +0000 Subject: [PATCH] Monotone-Parent: 3153e42cfafdd9f2a07623a78af07f4b4e837945 Monotone-Revision: 94cd3c2d69b764a47aa3032dde40735f50a696c9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-06T19:21:15 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 ++++++ .../Appointments/iCalEntityObject+SOGo.m | 32 +++---------------- UI/Scheduler/UIxDatePicker.m | 21 +++++++++++- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fda9625b..3953718d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2010-01-06 Wolfgang Sourdeau + * UI/Scheduler/UIxDatePicker.m + (-takeValuesFromRequest:inContext:): we set the new date to the + user's timezone and recompute the proper offset compare to the + system timezone, which may differ from it. + + * SoObjects/Appointments/iCalEntityObject+SOGo.m + (-quickRecordDateAsNumber:withOffset:forAllDay:): we only need to + compute the delta between the user's timezone and UTC rather than + the system timezone. + * SoObjects/Mailer/SOGoMailNamespace.m (-lookupName:inContext:acquire:): overriden method because the namespace "folders" cannot be created and cannot contain messages. diff --git a/SoObjects/Appointments/iCalEntityObject+SOGo.m b/SoObjects/Appointments/iCalEntityObject+SOGo.m index 108f3b736..51705067b 100644 --- a/SoObjects/Appointments/iCalEntityObject+SOGo.m +++ b/SoObjects/Appointments/iCalEntityObject+SOGo.m @@ -34,40 +34,16 @@ #import #import -#import -#import -#import +#import +#import +#import #import "iCalPerson+SOGo.h" #import "iCalEntityObject+SOGo.h" -static int utcOffset = -1; - @implementation iCalEntityObject (SOGoExtensions) -static inline int -_computeAllDayOffset() -{ - NSTimeZone *tz; - SOGoUser *user; - WOApplication *application; - int offset; - - if (utcOffset == -1) - { - tz = [[NSCalendarDate date] timeZone]; - utcOffset = [tz secondsFromGMT]; - } - - application = [WOApplication application]; - user = [[application context] activeUser]; - tz = [[user userDefaults] timeZone]; - offset = utcOffset - [tz secondsFromGMT]; - - return offset; -} - + (void) initializeSOGoExtensions; { if (!iCalDistantFuture) @@ -228,7 +204,7 @@ _computeAllDayOffset() { seconds = [_date timeIntervalSince1970] + offset; if (allDay) - seconds += _computeAllDayOffset (); + seconds += [[_date timeZone] secondsFromGMT]; dateNumber = [NSNumber numberWithInt: seconds]; } diff --git a/UI/Scheduler/UIxDatePicker.m b/UI/Scheduler/UIxDatePicker.m index d74d4c1a5..173d388fd 100644 --- a/UI/Scheduler/UIxDatePicker.m +++ b/UI/Scheduler/UIxDatePicker.m @@ -21,11 +21,15 @@ #import #import +#import -#import +#import #import #import +#import +#import + #import "UIxDatePicker.h" @implementation UIxDatePicker @@ -144,6 +148,9 @@ { NSString *dateString; NSCalendarDate *d; + NSInteger dateTZOffset, userTZOffset; + NSTimeZone *userTZ; + SOGoUserDefaults *ud; dateString = [_rq formValueForKey:[self dateID]]; if (dateString == nil) { @@ -158,6 +165,18 @@ dateString]; } + /* we must adjust the date timezone because "dateWithString:..." uses the + system timezone, which can be different from the user's. */ + ud = [[_ctx activeUser] userDefaults]; + dateTZOffset = [[d timeZone] secondsFromGMT]; + userTZ = [ud timeZone]; + userTZOffset = [userTZ secondsFromGMT]; + if (dateTZOffset != userTZOffset) + d = [d dateByAddingYears: 0 months: 0 days: 0 + hours: 0 minutes: 0 + seconds: (dateTZOffset - userTZOffset)]; + [d setTimeZone: userTZ]; + [self setDay: [NSNumber numberWithInt:[d dayOfMonth]]]; [self setMonth:[NSNumber numberWithInt:[d monthOfYear]]]; [self setYear: [NSNumber numberWithInt:[d yearOfCommonEra]]];