fixed timezone calculation on recurring event

pull/69/merge
Ludovic Marcotte 2015-01-15 15:29:02 -05:00
parent 16c863d89d
commit e9e3dd5646
3 changed files with 13 additions and 11 deletions

1
NEWS
View File

@ -13,6 +13,7 @@ Bug fixes
- fixed birthday offset in EAS - fixed birthday offset in EAS
- fixed From's full name over EAS - fixed From's full name over EAS
- fixed potential issue when handling multiple Add/Change/Delete/Fetch EAS commands (#3057) - 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) 2.2.13 (2014-12-30)
------------------- -------------------

View File

@ -156,13 +156,15 @@
[tzStart setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; [tzStart setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
tmpDate = [NSCalendarDate dateWithYear: [refDate yearOfCommonEra] tmpDate = [NSCalendarDate dateWithYear: [refDate yearOfCommonEra]
month: [[[rrule byMonth] objectAtIndex: 0] intValue] month: [[[rrule byMonth] objectAtIndex: 0] intValue]
day: 1 hour: [tzStart hourOfDay] day: 1
hour: [tzStart hourOfDay]
minute: [tzStart minuteOfHour] second: 0 minute: [tzStart minuteOfHour] second: 0
timeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; timeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
tmpDate = [tmpDate addYear: 0 month: ((pos > 0) ? 0 : 1) tmpDate = [tmpDate addYear: 0 month: ((pos > 0) ? 0 : 1)
day: 0 hour: 0 minute: 0 day: 0 hour: 0 minute: 0
second: 0]; second: 0];
/* If the day of the time change is "-XSU", we need to determine whether the /* 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 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 changes occurs on sundays, it will be false only when that first day is a
@ -171,10 +173,16 @@
if (dateDayOfWeek > dayOfWeek && pos < 0) if (dateDayOfWeek > dayOfWeek && pos < 0)
pos++; 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); offset = (dayOfWeek - dateDayOfWeek) + (pos * 7);
tmpDate = [tmpDate addYear: 0 month: 0 day: offset tmpDate = [tmpDate addYear: 0 month: 0 day: offset
hour: 0 minute: 0 second: 0]; hour: 0 minute: 0 second: 0];
return tmpDate; return tmpDate;
} }

View File

@ -926,11 +926,6 @@ static Class iCalEventK = nil;
dateSecs = [NSNumber numberWithInt: [date timeIntervalSince1970]]; dateSecs = [NSNumber numberWithInt: [date timeIntervalSince1970]];
[record setObject: dateSecs forKey: @"c_enddate"]; [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; return record;
} }
@ -1103,9 +1098,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
[newRecord setObject: dateSecs forKey: @"c_recurrence_id"]; [newRecord setObject: dateSecs forKey: @"c_recurrence_id"];
[newRecord setObject: [NSNumber numberWithInt: 1] forKey: @"c_iscycle"]; [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. // We identified the record as an exception.
[newRecord setObject: [NSNumber numberWithInt: 1] forKey: @"isException"]; [newRecord setObject: [NSNumber numberWithInt: 1] forKey: @"isException"];