Permalink
Browse files

Issue 47. Fix occurence count tracking for the BYMONTH rrule.

  • Loading branch information...
Aleksey Vorona
Aleksey Vorona committed Sep 18, 2015
1 parent 764878f commit 0dea8f1cc52f9718bf4c737e26a16bd0415d9e89
@@ -594,7 +594,7 @@ public final DateList getDates(final Date seed, final Date periodStart,
}
}
int invalidCandidateCount = 0;
HashSet<Date> invalidCandidates = new HashSet<Date>();
int noCandidateIncrementCount = 0;
Date candidate = null;
while ((maxCount < 0) || (dates.size() < maxCount)) {
@@ -611,7 +611,7 @@ public final DateList getDates(final Date seed, final Date periodStart,
break;
}
if (getCount() >= 1
&& (dates.size() + invalidCandidateCount) >= getCount()) {
&& (dates.size() + invalidCandidates.size()) >= getCount()) {
break;
}
@@ -637,9 +637,9 @@ public final DateList getDates(final Date seed, final Date periodStart,
// candidates exclusive of periodEnd..
if (candidate.before(periodStart)
|| !candidate.before(periodEnd)) {
invalidCandidateCount++;
invalidCandidates.add(candidate);
} else if (getCount() >= 1
&& (dates.size() + invalidCandidateCount) >= getCount()) {
&& (dates.size() + invalidCandidates.size()) >= getCount()) {
break;
} else if (!(getUntil() != null
&& candidate.after(getUntil()))) {
@@ -833,6 +833,13 @@ public static TestSuite suite() throws ParseException {
recur = new Recur("FREQ=DAILY;COUNT=3;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR");
suite.addTest(new RecurTest(recur, new DateTime("20131215T000000Z"),
new DateTime("20131215T000000Z"), new DateTime("20180101T120000Z"), Value.DATE_TIME, 3));
// rrule with bymonth and count. Should return correct number of occurrences near the end of its perioud.
recur = new Recur("FREQ=MONTHLY;COUNT=3;INTERVAL=1;BYMONTH=1,9,10,12;BYMONTHDAY=12");
suite.addTest(new RecurTest(recur, new DateTime("20150917T000000Z"),
new DateTime("20160101T000000Z"), new DateTime("20160201T000000Z"), Value.DATE, 1));
suite.addTest(new RecurTest(recur, new DateTime("20150917T000000Z"),
new DateTime("20160201T000000Z"), new DateTime("20160301T000000Z"), Value.DATE, 0));
return suite;
}

0 comments on commit 0dea8f1

Please sign in to comment.