}
protected Calendar prepareCal(Calendar cal) {
// Performs a "sane" skip forward in time - avoids time consuming loops
// like incrementing every second from Jan 1 2000 until today
Calendar skip = (Calendar) cal.clone();
skip.setTime(this.start);
long deltaMillis = cal.getTimeInMillis() - this.start.getTime();
if (deltaMillis < 1000) {
return skip;
}
long divisor = deltaMillis;
if (this.freqType == Calendar.DAY_OF_MONTH) {
divisor = 86400000;
} else if (this.freqType == Calendar.HOUR) {
divisor = 3600000;
} else if (this.freqType == Calendar.MINUTE) {
divisor = 60000;
} else if (this.freqType == Calendar.SECOND) {
divisor = 1000;
} else {
return skip;
}
float units = deltaMillis / divisor;
units = (units / this.freqCount) * this.freqCount;
skip.add(this.freqType, (int)units);
while (skip.after(cal)) {
skip.add(this.freqType, -this.freqCount);
}
return skip;
}