From e9e3dd5646cdf004896f350e35fddd661463f029 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 15 Jan 2015 15:29:02 -0500 Subject: [PATCH] fixed timezone calculation on recurring event --- NEWS | 1 + SOPE/NGCards/iCalTimeZonePeriod.m | 14 +++++++++++--- SoObjects/Appointments/SOGoAppointmentFolder.m | 9 +-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index cd160edac..7e9cb880a 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Bug fixes - fixed birthday offset in EAS - fixed From's full name over EAS - fixed potential issue when handling multiple Add/Change/Delete/Fetch EAS commands (#3057) + - fixed wrong timezone calculation on recurring events 2.2.13 (2014-12-30) ------------------- diff --git a/SOPE/NGCards/iCalTimeZonePeriod.m b/SOPE/NGCards/iCalTimeZonePeriod.m index 5da8db47a..41435c163 100644 --- a/SOPE/NGCards/iCalTimeZonePeriod.m +++ b/SOPE/NGCards/iCalTimeZonePeriod.m @@ -156,13 +156,15 @@ [tzStart setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; tmpDate = [NSCalendarDate dateWithYear: [refDate yearOfCommonEra] month: [[[rrule byMonth] objectAtIndex: 0] intValue] - day: 1 hour: [tzStart hourOfDay] + day: 1 + hour: [tzStart hourOfDay] minute: [tzStart minuteOfHour] second: 0 timeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; + tmpDate = [tmpDate addYear: 0 month: ((pos > 0) ? 0 : 1) day: 0 hour: 0 minute: 0 second: 0]; - + /* If the day of the time change is "-XSU", we need to determine whether the first day of next month is in the same week. In practice, as most time changes occurs on sundays, it will be false only when that first day is a @@ -171,10 +173,16 @@ if (dateDayOfWeek > dayOfWeek && pos < 0) pos++; + /* We check if the day of hte week is identical. This is important because if they + are, "pos" actually includes the first day of tmpDate which means we must decrement + pos by 1 */ + if (dayOfWeek == dateDayOfWeek) + pos--; + offset = (dayOfWeek - dateDayOfWeek) + (pos * 7); tmpDate = [tmpDate addYear: 0 month: 0 day: offset hour: 0 minute: 0 second: 0]; - + return tmpDate; } diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index c3e29c9ca..fc1552235 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -926,11 +926,6 @@ static Class iCalEventK = nil; dateSecs = [NSNumber numberWithInt: [date timeIntervalSince1970]]; [record setObject: dateSecs forKey: @"c_enddate"]; - // The first instance date is added to the dictionary so it can - // be used by UIxCalListingActions to compute the DST offset. - date = [theFirstCycle startDate]; - [record setObject: date forKey: @"cycleStartDate"]; - return record; } @@ -1103,9 +1098,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir [newRecord setObject: dateSecs forKey: @"c_recurrence_id"]; [newRecord setObject: [NSNumber numberWithInt: 1] forKey: @"c_iscycle"]; - // The first instance date is added to the dictionary so it can - // be used by UIxCalListingActions to compute the DST offset. - [newRecord setObject: [fir startDate] forKey: @"cycleStartDate"]; + // We identified the record as an exception. [newRecord setObject: [NSNumber numberWithInt: 1] forKey: @"isException"];