diff --git a/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java b/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java index db85f20ccc..50365b4ed5 100644 --- a/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java +++ b/source/java/org/alfresco/repo/calendar/CalendarHelpersTest.java @@ -201,6 +201,18 @@ public class CalendarHelpersTest assertEquals("2011-07-29", dateFmt.format(dates.get(9))); + // From before today, full time set + dates.clear(); + currentDate.set(2011,11-1,24,10,30); + RecurrenceHelper.buildDailyRecurrences( + currentDate, dates, null, + date(2011,11,22,12,30), date(2011,11,25,12,30), + false, 1); + assertEquals(2, dates.size()); + assertEquals("2011-11-24", dateFmt.format(dates.get(0))); // Thu + assertEquals("2011-11-25", dateFmt.format(dates.get(1))); // Fri + + // With no end date but only first, check it behaves dates.clear(); currentDate.set(2011,7-1,19,10,30); @@ -269,6 +281,17 @@ public class CalendarHelpersTest assertEquals("2011-07-25", dateFmt.format(dates.get(1))); // Mon + // Just before today, full time set + dates.clear(); + currentDate.set(2011,11-1,24,10,30); + RecurrenceHelper.buildWeeklyRecurrences( + currentDate, dates, params, + date(2011,11,22,12,30), date(2011,11,25,12,30), + false, 1); + assertEquals(1, dates.size()); + assertEquals("2011-11-24", dateFmt.format(dates.get(0))); // Thu + + // From today dates.clear(); currentDate.set(2011,7-1,19,10,30); diff --git a/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java b/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java index 2938a486ba..20abffb03d 100644 --- a/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java +++ b/source/java/org/alfresco/service/cmr/calendar/CalendarRecurrenceHelper.java @@ -127,7 +127,8 @@ public class CalendarRecurrenceHelper * For the given Calendar Entry, return its subsequent Recurrence on or after * the specified date, until the given limit. If it doesn't have any recurrences * on or after the start date (either no recurrence rules, or the last recurrence - * date is before then), null will be returned. + * date is before then), null will be returned. (The onOrAfter and until dates + * are treat as inclusive) * If requested, can stop after the first hit * @return The next recurrence on or after the given date, or null if there aren't any */ @@ -143,7 +144,8 @@ public class CalendarRecurrenceHelper * For the given Calendar Entry, return its subsequent Recurrence on or after * the specified date, until the given limit. If it doesn't have any recurrences * on or after the start date (either no recurrence rules, or the last recurrence - * date is before then), null will be returned. + * date is before then), null will be returned. (The onOrAfter and until dates + * are treat as inclusive) * If requested, can stop after the first hit * @return The next recurrence on or after the given date, or null if there aren't any */ @@ -273,7 +275,7 @@ public class CalendarRecurrenceHelper else { // Run until the end - while (currentDate.getTime().before(until)) + while (! currentDate.getTime().after(until)) { dates.add(currentDate.getTime()); currentDate.add(Calendar.DATE, 1);