@Override
protected MutableInterval _nextMutableInterval(PointerType pointer) {
int halfDay = RepeaterDay.DAY_SECONDS / 2;
int fullDay = RepeaterDay.DAY_SECONDS;
DateTime now = getNow();
Tick tick = getType();
boolean first = false;
if (_currentTime == null) {
first = true;
DateTime midnight = Time.ymd(now);
DateTime yesterdayMidnight = midnight.minusSeconds(fullDay);
DateTime tomorrowMidnight = midnight.plusSeconds(fullDay);
boolean done = false;
if (pointer == Pointer.PointerType.FUTURE) {
if (tick.isAmbiguous()) {
List<DateTime> futureDates = new LinkedList<DateTime>();
futureDates.add( midnight.plusSeconds(tick.intValue()));
futureDates.add(midnight.plusSeconds( halfDay + tick.intValue()));
futureDates.add(tomorrowMidnight.plusSeconds(tick.intValue()));
for (DateTime futureDate : futureDates) {
if (futureDate.getMillis() > now.getMillis() || futureDate.equals(now)) {
_currentTime = futureDate;
done = true;
break;
}
}
}
else {
List<DateTime> futureDates = new LinkedList<DateTime>();
futureDates.add(midnight.plusSeconds(tick.intValue()));
futureDates.add(tomorrowMidnight.plusSeconds(tick.intValue()));
for (DateTime futureDate : futureDates) {
if (futureDate.getMillis() > now.getMillis() || futureDate.equals(now)) {
_currentTime = futureDate;
done = true;
break;