Search in sources :

Example 1 with DateRange

use of com.github.drbookings.DateRange in project drbookings by DrBookings.

the class MainManager method fillMissing.

private void fillMissing() {
    final List<LocalDate> dates = new ArrayList<>(uiDataMap.keySet());
    Collections.sort(dates);
    final Collection<LocalDate> toAdd = new HashSet<>();
    LocalDate last = null;
    for (final LocalDate d : dates) {
        if (last != null) {
            if (d.equals(last.plusDays(1))) {
            // ok
            } else {
                toAdd.addAll(new DateRange(last.plusDays(1), d.minusDays(1)).toList());
            }
        }
        last = d;
    }
    for (final LocalDate d : toAdd) {
        addDateBean(new DateBean(d, this));
    }
}
Also used : DateRange(com.github.drbookings.DateRange) DateBean(com.github.drbookings.ui.beans.DateBean) LocalDate(java.time.LocalDate)

Aggregations

DateRange (com.github.drbookings.DateRange)1 DateBean (com.github.drbookings.ui.beans.DateBean)1 LocalDate (java.time.LocalDate)1