Upstream biweekly patch

pull/214/head
M66B 10 months ago
parent 1b3bfd2d96
commit 6b3c7078e1

@ -416,25 +416,26 @@ public class ICalTimeZone extends TimeZone {
RecurrenceIterator it = createIterator(observance); RecurrenceIterator it = createIterator(observance);
/* /*
* The "advanceTo()" method skips all dates that are less than the * Calling "it.advanceTo()" here causes problems.
* given date. I would have thought that we would have to call *
* "next()" once because we want it to skip the date that is equal * See: https://github.com/mangstadt/biweekly/issues/126
* to the "last" date. But this causes all the unit tests to fail,
* so I guess not.
*/ */
//it.advanceTo(last); //it.advanceTo(last);
//it.next();
DateValue prev = null, cur = null; DateValue prev = null, cur = null;
boolean stopped = false; boolean stopped = false;
while (it.hasNext()) { while (it.hasNext()) {
cur = it.next(); cur = it.next();
int curComparison = cur.compareTo(last); int curCompareToLast = cur.compareTo(last);
if (curComparison < 0) continue; if (curCompareToLast < 0) {
continue;
if (curComparison > 0) { }
if (curCompareToLast > 0) {
dateCache.add(cur); dateCache.add(cur);
} }
if (curCompareToLast == 0) {
//do nothing; don't add to dateCache
}
if (givenDate.compareTo(cur) < 0) { if (givenDate.compareTo(cur) < 0) {
//stop if we have passed the givenTime //stop if we have passed the givenTime
@ -444,7 +445,8 @@ public class ICalTimeZone extends TimeZone {
prev = cur; prev = cur;
} }
return after ? (stopped ? cur : null) : prev; } return after ? (stopped ? cur : null) : prev;
}
/* /*
* The date is somewhere in the cached list, so find it. * The date is somewhere in the cached list, so find it.

Loading…
Cancel
Save