Skip to content

Commit

Permalink
(fix) fix events in floating time during CalDAV's PUT operation (fixe…
Browse files Browse the repository at this point in the history
…s #2865)
  • Loading branch information
extrafu authored and cgx committed Jan 7, 2017
1 parent 22acfc9 commit 7837343
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -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];
Expand Down
49 changes: 49 additions & 0 deletions SoObjects/Appointments/SOGoAppointmentObject.m
Expand Up @@ -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;
Expand Down Expand Up @@ -1940,6 +1988,7 @@ - (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar
[self _adjustEventsInRequestCalendar: calendar];
[self adjustClassificationInRequestCalendar: calendar];
[self _adjustPartStatInRequestCalendar: calendar];
[self _adjustFloatingTimeInRequestCalendar: calendar];
}

//
Expand Down

0 comments on commit 7837343

Please sign in to comment.