From 8b02db7b8cca7809e7e2f46ea29b6a08007c4744 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 12 Oct 2017 10:19:01 -0400 Subject: [PATCH] Fix yearly recurrences calculator with until date --- NEWS | 1 + SOPE/NGCards/iCalYearlyRecurrenceCalculator.m | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 1f16b2283..66cb40df1 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ Enhancements Bug fixes - [core] yearly repeating events are not shown in web calendar (#4237) - [core] increased column size of settings/defaults for MySQL (#4260) + - [core] fixed yearly recurrence calculator with until date - [web] fixed display of error when the mail editor is in a popup - [web] attachments are not displayed on IOS (#4150) - [web] fixed parsing of pasted email addresses from Spreadsheet (#4258) diff --git a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m index 0aa339750..aa5e9c4fc 100644 --- a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m @@ -91,7 +91,7 @@ if ([lastDate compare: rStart] == NSOrderedAscending) // Range starts after last occurrence return nil; - if ([lastDate compare: rEnd] == NSOrderedDescending) + if ([lastDate compare: rEnd] == NSOrderedAscending) // Range ends after last occurence; adjust end date rEnd = lastDate; } @@ -212,14 +212,17 @@ months: 0 days: 0]; [start setTimeZone: [firStart timeZone]]; - end = [start addTimeInterval: [firstRange duration]]; - r = [NGCalendarDateRange calendarDateRangeWithStartDate: start - endDate: end]; - if ([_r doesIntersectWithDateRange: r] && (repeatCount == 0 || count < repeatCount)) - { - [ranges addObject: r]; - count++; - } + if ([start compare: rEnd] == NSOrderedAscending) + { + end = [start addTimeInterval: [firstRange duration]]; + r = [NGCalendarDateRange calendarDateRangeWithStartDate: start + endDate: end]; + if ([_r doesIntersectWithDateRange: r] && (repeatCount == 0 || count < repeatCount)) + { + [ranges addObject: r]; + count++; + } + } } } else