From ed80559b0517af9bc1176c7de64160c98074a9ea Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 22 Apr 2010 13:15:04 +0000 Subject: [PATCH] See ChangeLogs. Monotone-Parent: 8d68561f51adcd8910568babcba5d38587755f06 Monotone-Revision: 18a37cc2e34898697d26aa8ab49aaab61673a465 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-04-22T13:15:04 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++ SOPE/NGCards/ChangeLog | 12 +++++++ SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m | 5 ++- SOPE/NGCards/iCalYearlyRecurrenceCalculator.m | 32 +++++++++++-------- Tests/Unit/GNUmakefile | 1 + 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2088e450..1778c4f1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-22 Francis Lachapelle + + * Tests/Unit/TestiCalRecurrenceCalculator.m: new test module for + iCalRecurrenceRule. Added full test method for + recurrenceRangesWithinCalendarDateRange:. + 2010-04-21 Wolfgang Sourdeau * Main/SOGo+DAV.m: commented out incomplete code for handling diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 98b418634..dfa4ac926 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,15 @@ +2010-04-22 Francis Lachapelle + + * iCalYearlyRecurrenceCalculator.m + (-recurrenceRangesWithinCalendarDateRange:): the rule interval + must be reset to 1 when using the monthly calculator since the + interval is related to the yearly frequency. Also fixed the month + counter with respect to the recurrence interval. + + * iCalWeeklyRecurrenceCalculator.m + (-recurrenceRangesWithinCalendarDateRange:): fixed the computation + of the week number which results in a bad verification of the interval. + 2010-04-19 Francis Lachapelle * iCalByDayMask.[h|m]: new class that computes complex BYDAY constraints. diff --git a/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m b/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m index 40d525f0f..969990ee3 100644 --- a/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m @@ -168,8 +168,11 @@ { [currentStartDate years:NULL months:NULL days:(int *)&days hours:NULL minutes:NULL seconds:NULL sinceDate: firStart]; - week = days / 7; + // The following adjustment always set the first day of the + // week to Sunday, ie WKST is ignored. + week = (days + [firStart dayOfWeek]) / 7; + if ((week % interval) == 0 && [dayMask occursOnDay: [currentStartDate dayOfWeek]]) isRecurrence = YES; diff --git a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m index c625c65b5..866642caa 100644 --- a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m @@ -120,12 +120,12 @@ */ // Instantiate a MONTHLY calculator - if (repeatCount > 0) - // Fool the monthly calculator, otherwise it will verify the COUNT - // constraint and perform the calculation from the first occurence of - // the recurrence. This calculation is performed by the current method. - [rrule setRepeatCount: 0]; - + // Fool the monthly calculator, otherwise it will verify the COUNT + // constraint and perform the calculation from the first occurence of + // the recurrence. This calculation is performed by the current method. + // The interval must be ignored as well since it refers to the years. + [rrule setRepeatCount: 0]; + [rrule setInterval: @"1"]; monthlyCalc = [[iCalMonthlyRecurrenceCalculator alloc] initWithRecurrenceRule: rrule firstInstanceCalendarDateRange: firstRange]; @@ -161,7 +161,7 @@ currentMonth = [referenceDate monthOfYear]; for (yearIdxInRange = 0 ; yearIdxInRange < numberOfYearsInRange; yearIdxInRange++) { - int test, year; + int k, test, year; test = diff + yearIdxInRange; if ((test >= 0) && (test % interval) == 0) @@ -184,12 +184,11 @@ days: 0]; rEnd = [rStart dateByAddingYears: 0 months: 0 - days: [rStart numberOfDaysInMonth] - 1]; + days: [rStart numberOfDaysInMonth]]; rangeForMonth = [NGCalendarDateRange calendarDateRangeWithStartDate: rStart endDate: rEnd]; rangesInMonth = [monthlyCalc recurrenceRangesWithinCalendarDateRange: rangeForMonth]; - int k; for (k = 0; k < [rangesInMonth count] && (repeatCount == 0 || count < repeatCount); k++) { //NSLog(@"*** YEARLY found %@ (count = %i)", [[rangesInMonth objectAtIndex: k] startDate], count); count++; @@ -224,12 +223,19 @@ } } } + else + { + // Year was skipped, added 12 months to the counter + monthDiff += 12; + } } - if (byMonth && repeatCount > 0) - // Restore the repeat count - [rrule setRepeatCount: repeatCount]; - + if (byMonth) + { + // Restore the repeat count and interval + [rrule setRepeatCount: repeatCount]; + [rrule setRepeatInterval: interval]; + } return ranges; } diff --git a/Tests/Unit/GNUmakefile b/Tests/Unit/GNUmakefile index 6439fd442..e6afe78c3 100644 --- a/Tests/Unit/GNUmakefile +++ b/Tests/Unit/GNUmakefile @@ -15,6 +15,7 @@ $(TEST_TOOL)_OBJC_FILES += \ SOGoTestRunner.m \ \ TestiCalTimeZonePeriod.m \ + TestiCalRecurrenceCalculator.m \ \ TestBSJSONAdditions.m