protected MutableInterval _nextMutableInterval(PointerType pointer) {
if (_currentWeekStart == null) {
if (pointer == Pointer.PointerType.FUTURE) {
RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
saturdayRepeater.setStart( new DateTime(getNow()));
MutableInterval nextSaturdayMutableInterval = saturdayRepeater.nextMutableInterval(Pointer.PointerType.FUTURE);
_currentWeekStart = nextSaturdayMutableInterval.getStart();
}
else if (pointer == Pointer.PointerType.PAST) {
RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
saturdayRepeater.setStart(Time.cloneAndAdd(getNow(), Time.SECOND, RepeaterDay.DAY_SECONDS));
MutableInterval lastSaturdayMutableInterval = saturdayRepeater.nextMutableInterval(Pointer.PointerType.PAST);
_currentWeekStart = lastSaturdayMutableInterval.getStart();
}
}
else {
int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
_currentWeekStart = Time.cloneAndAdd(_currentWeekStart, Time.SECOND, direction * RepeaterWeek.WEEK_SECONDS);
}
return new MutableInterval(_currentWeekStart, Time.cloneAndAdd(_currentWeekStart, Time.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
}