protected Span _nextSpan(PointerType pointer) {
if (_currentWeekStart == null) {
if (pointer == Pointer.PointerType.FUTURE) {
RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
saturdayRepeater.setStart((Calendar) getNow().clone());
Span nextSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.FUTURE);
_currentWeekStart = nextSaturdaySpan.getBeginCalendar();
}
else if (pointer == Pointer.PointerType.PAST) {
RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
saturdayRepeater.setStart(Time.cloneAndAdd(getNow(), Calendar.SECOND, RepeaterDay.DAY_SECONDS));
Span lastSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.PAST);
_currentWeekStart = lastSaturdaySpan.getBeginCalendar();
}
}
else {
int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
_currentWeekStart = Time.cloneAndAdd(_currentWeekStart, Calendar.SECOND, direction * RepeaterWeek.WEEK_SECONDS);
}
return new Span(_currentWeekStart, Time.cloneAndAdd(_currentWeekStart, Calendar.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
}