ALF-6356 Correct repeating events handling of the last instance by day

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32282 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-11-24 14:28:55 +00:00
parent c23974a0fc
commit f939783d70
2 changed files with 28 additions and 3 deletions

View File

@@ -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);

View File

@@ -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);