From d7bca942999712f66d16e6127cf9c66ad4b73e58 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 12 Mar 2010 20:24:59 +0000 Subject: [PATCH] Monotone-Parent: c36e4dbaaa40c95b58d682bbbe6f0a563275afa1 Monotone-Revision: a0ddb6969a3af4885bc30844a5dc0bcda95a8212 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-03-12T20:24:59 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++ .../Appointments/SOGoAppointmentObject.m | 45 ++++++++++++++----- UI/Scheduler/UIxAppointmentEditor.m | 26 +---------- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f6ca52fc..4d9a92c04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-03-12 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentObject.m + (-newOccurenceWithID): moved timezone handling code from + UIxAppointmentEditor to here. Simplified that code. + 2010-03-11 Wolfgang Sourdeau * SoObjects/SOGo/SOGoUserFolder.m (_davFetchUsersMatching:): we diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 947546bed..9628f25db 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -23,6 +23,7 @@ #import #import #import +#import #import #import @@ -79,14 +80,33 @@ - (iCalRepeatableEntityObject *) newOccurenceWithID: (NSString *) recID { - iCalEvent *newOccurence; - NSCalendarDate *date; + iCalEvent *newOccurence, *master; + NSCalendarDate *date, *firstDate; unsigned int interval, nbrDays; + SOGoUserDefaults *ud; + NSTimeZone *timeZone; + int daylightOffset; + + ud = [[SOGoUser userWithLogin: owner] userDefaults]; + timeZone = [ud timeZone]; newOccurence = (iCalEvent *) [super newOccurenceWithID: recID]; date = [newOccurence recurrenceId]; - interval = [[newOccurence endDate] - timeIntervalSinceDate: [newOccurence startDate]]; + + master = [self component: NO secure: NO]; + firstDate = [master startDate]; + + // 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. + daylightOffset = (int) ([timeZone secondsFromGMTForDate: firstDate] + - [timeZone secondsFromGMTForDate: date]); + if (daylightOffset) + date = [date dateByAddingYears: 0 months: 0 days: 0 + hours:0 minutes: 0 seconds: daylightOffset]; + [date setTimeZone: timeZone]; + + interval = [[master endDate] + timeIntervalSinceDate: firstDate]; if ([newOccurence isAllDay]) { nbrDays = ((float) abs (interval) / 86400) + 1; @@ -94,14 +114,15 @@ duration: nbrDays]; } else - [newOccurence setStartDate: date]; - - [newOccurence setEndDate: [date addYear: 0 - month: 0 - day: 0 - hour: 0 - minute: 0 - second: interval]]; + { + [newOccurence setStartDate: date]; + [newOccurence setEndDate: [date addYear: 0 + month: 0 + day: 0 + hour: 0 + minute: 0 + second: interval]]; + } return newOccurence; } diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index 3a87a5b63..cbfabe564 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -276,33 +276,11 @@ } else { - NSCalendarDate *firstDate; - iCalEvent *master; - signed int daylightOffset; - 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]; - - 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]; + endDate = [event endDate]; if (isAllDay) - endDate = [[event endDate] dateByAddingYears: 0 months: 0 days: -1]; - else - endDate = [[event endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset]; + endDate = [endDate dateByAddingYears: 0 months: 0 days: -1]; isTransparent = ![event isOpaque]; }