diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index b947c0922c..e8e8fdae3b 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3241,7 +3241,8 @@ - (int) importCalendar: (iCalCalendar *) calendar else { // If the start date is a "floating time", let's use the user's timezone - // during the import for both the start and end dates. + // during the import for both the start and end dates. This is similar + // to what we do in SOGoAppointmentObject: -_adjustFloatingTimeInRequestCalendar: NSString *s; s = [[startDate valuesAtIndex: 0 forKey: @""] objectAtIndex: 0]; diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 04721deab0..e2437551a3 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -1819,6 +1819,54 @@ - (void) _adjustEventsInRequestCalendar: (iCalCalendar *) rqCalendar } } +// +// This is similar to what we do in SOGoAppointmentFolder: -importCalendar: +// +- (void) _adjustFloatingTimeInRequestCalendar: (iCalCalendar *) rqCalendar +{ + iCalDateTime *startDate, *endDate; + NSString *startDateAsString; + SOGoUserDefaults *ud; + NSArray *allEvents; + iCalTimeZone *tz; + iCalEvent *event; + int i, delta; + + allEvents = [rqCalendar events]; + for (i = 0; i < [allEvents count]; i++) + { + event = [allEvents objectAtIndex: i]; + + if ([event isAllDay]) + continue; + + startDate = (iCalDateTime *)[event uniqueChildWithTag: @"dtstart"]; + startDateAsString = [[startDate valuesAtIndex: 0 forKey: @""] objectAtIndex: 0]; + + if (![startDate timeZone] && + ![startDateAsString hasSuffix: @"Z"] && + ![startDateAsString hasSuffix: @"z"]) + { + ud = [[context activeUser] userDefaults]; + tz = [iCalTimeZone timeZoneForName: [ud timeZoneName]]; + if ([rqCalendar addTimeZone: tz]) + { + delta = [[tz periodForDate: [startDate dateTime]] secondsOffsetFromGMT]; + + [event setStartDate: [[event startDate] dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -delta]]; + [startDate setTimeZone: tz]; + + endDate = (iCalDateTime *) [event uniqueChildWithTag: @"dtend"]; + if (endDate) + { + [event setEndDate: [[event endDate] dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -delta]]; + [endDate setTimeZone: tz]; + } + } + } + } +} + - (void) _decomposeGroupsInRequestCalendar: (iCalCalendar *) rqCalendar { NSArray *allEvents; @@ -1940,6 +1988,7 @@ - (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar [self _adjustEventsInRequestCalendar: calendar]; [self adjustClassificationInRequestCalendar: calendar]; [self _adjustPartStatInRequestCalendar: calendar]; + [self _adjustFloatingTimeInRequestCalendar: calendar]; } //