diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 836d325a8..d9f7cba2e 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,10 @@ +2012-02-03 Francis Lachapelle + + * iCalDailyRecurrenceCalculator.m + (-recurrenceRangesWithinCalendarDateRange): handle the case + where the occurrence start date doesn't cover the reference period + but the end date does. + 2012-01-11 Wolfgang Sourdeau * NSString+NGCards.m (-asCardAttributeValues): fixed a leak by diff --git a/SOPE/NGCards/iCalDailyRecurrenceCalculator.m b/SOPE/NGCards/iCalDailyRecurrenceCalculator.m index 728d0dec2..04106dab4 100644 --- a/SOPE/NGCards/iCalDailyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalDailyRecurrenceCalculator.m @@ -144,26 +144,29 @@ break; } - if (wrongDay == NO && - ([startDate compare: currentStartDate] == NSOrderedAscending || - [startDate compare: currentStartDate] == NSOrderedSame)) - { - NGCalendarDateRange *r; + if (wrongDay == NO) + { + currentEndDate = [currentStartDate addTimeInterval: [firstRange duration]]; + if ([startDate compare: currentStartDate] == NSOrderedAscending || + [startDate compare: currentStartDate] == NSOrderedSame || + [startDate compare: currentEndDate] == NSOrderedAscending) + { + NGCalendarDateRange *r; - if (isFirStart == NO && dayMask && repeatCount == 0) - { - if (![dayMask occursOnDay: [currentStartDate dayOfWeek]]) - wrongDay = YES; - } - - if (isFirStart == YES || wrongDay == NO) - { - currentEndDate = [currentStartDate addTimeInterval: [firstRange duration]]; - r = [NGCalendarDateRange calendarDateRangeWithStartDate: currentStartDate - endDate: currentEndDate]; - if ([_r containsDateRange: r] || [_r doesIntersectWithDateRange: r]) - [ranges addObject: r]; - } + if (isFirStart == NO && dayMask && repeatCount == 0) + { + if (![dayMask occursOnDay: [currentStartDate dayOfWeek]]) + wrongDay = YES; + } + + if (isFirStart == YES || wrongDay == NO) + { + r = [NGCalendarDateRange calendarDateRangeWithStartDate: currentStartDate + endDate: currentEndDate]; + if ([_r containsDateRange: r] || [_r doesIntersectWithDateRange: r]) + [ranges addObject: r]; + } + } } currentStartDate = [firStart dateByAddingYears: 0 months: 0