From dfe906cffc7c5f9c0075098aa9c8ea1e34775ebd Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 3 Feb 2012 16:00:44 +0000 Subject: [PATCH] See ChangeLog. Monotone-Parent: 41ae9527101a616e7849988930fe0399bf14919f Monotone-Revision: dd31018a0c1b88afe90d371ba63164a518d02876 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-02-03T16:00:44 --- SOPE/NGCards/ChangeLog | 7 ++++ SOPE/NGCards/iCalDailyRecurrenceCalculator.m | 41 +++++++++++--------- 2 files changed, 29 insertions(+), 19 deletions(-) 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