Skip to content

Commit

Permalink
Remove currently useless smartIncrement
Browse files Browse the repository at this point in the history
It was superseded by implicit rule in getCandidates(..)
  • Loading branch information
spitty committed Feb 8, 2020
1 parent f1dfb00 commit 3174697
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions src/main/java/net/fortuna/ical4j/model/Recur.java
Expand Up @@ -696,10 +696,7 @@ public final DateList getDates(final Date seed, final Date periodStart,
Calendar seededCal = (Calendar) cal.clone();
while (seededCal.getTime().before(periodStart)) {
cal.setTime(seededCal.getTime());
seededCal = smartIncrement(seededCal);
if (seededCal == null) {
return dates;
}
increment(seededCal);
}
}

Expand Down Expand Up @@ -764,10 +761,7 @@ public final DateList getDates(final Date seed, final Date periodStart,
break;
}
}
cal = smartIncrement(cal);
if (cal == null) {
break;
}
increment(cal);
}
// sort final list..
Collections.sort(dates);
Expand Down Expand Up @@ -869,34 +863,6 @@ private void increment(final Calendar cal) {
cal.add(calIncField, calInterval);
}

private Calendar smartIncrement(final Calendar cal) {
// initialise interval..
Calendar result = null;
final int calInterval = (getInterval() >= 1) ? getInterval() : 1;
int multiplier = 1;
if (calIncField == 2 || calIncField == 1) {
Calendar seededCal;
// increment up to 12 times to check for next valid occurence.
// as this loop only increments monthly or yearly,
// a monthly occurence will be found in (0,12] increments
// and a valid yearly recurrence will be found within (0,4]
// (ex. recurrence on February 29 on a leap year will find the next occurrence on the next leap year).
// if none found in these, return null.
do {
seededCal = (Calendar) cal.clone();
seededCal.add(calIncField, calInterval * multiplier);
multiplier++;
} while (seededCal.get(Calendar.DAY_OF_MONTH) != cal.get(Calendar.DAY_OF_MONTH) && multiplier <= 12);
if (multiplier <= 12) {
result = (Calendar) seededCal.clone();
}
} else {
result = (Calendar) cal.clone();
result.add(calIncField, calInterval);
}
return result;
}

/**
* Returns a list of possible dates generated from the applicable BY* rules, using the specified date as a seed.
*
Expand Down

0 comments on commit 3174697

Please sign in to comment.