Example usage for org.joda.time DateTime plusMinutes

List of usage examples for org.joda.time DateTime plusMinutes

Introduction

In this page you can find the example usage for org.joda.time DateTime plusMinutes.

Prototype

public DateTime plusMinutes(int minutes) 

Source Link

Document

Returns a copy of this datetime plus the specified number of minutes.

Usage

From source file:divconq.scheduler.limit.LimitHelper.java

License:Open Source License

public boolean checkForRun(DateTime v) {
    if (this.zone != null)
        v = new DateTime(v, this.zone);

    // if this time was ended at mid or before midnight then entire day is blocked
    if (this.isEnded(v))
        return false;

    // if this time was not started by the end of the then entire day is blocked
    if (!this.isStarted(v))
        return false;

    // runs must also be now (recent) or future
    if (v.plusMinutes(5).isBeforeNow())
        return false;

    if (this.parent != null)
        return this.parent.checkForRun(v);

    CheckInfo ci = new CheckInfo();
    ci.setWhen(v);/*from www .  j a  va2  s . c o m*/

    // if there are any months, those take precedence over other
    if (this.monthly.size() > 0) {
        for (MonthWindow ww : this.monthly)
            if (ww.appliesTo(ci))
                return (ww.check(ci) == CheckLimitResult.Pass);

        return false;
    }
    // if there are any weeks, those take precedence over daily
    else if (this.weekly.size() > 0) {
        for (WeekdayWindow ww : this.weekly)
            if (ww.appliesTo(ci))
                return (ww.check(ci) == CheckLimitResult.Pass);

        return false;
    }

    return (this.dailyWindow.check(v) == CheckLimitResult.Pass);
}

From source file:divconq.scheduler.limit.LimitHelper.java

License:Open Source License

public DateTime nextAllowedRunAfter(DateTime lin) {
    if (this.zone != null)
        lin = new DateTime(lin, this.zone);

    // cannot run before now - 2 minutes
    if (lin.plusMinutes(5).isBeforeNow())
        lin = new DateTime().minusMinutes(1); // start back one minute so we can start on time

    // cannot run again
    if (this.isEnded(lin))
        return null;

    // must start at least at "from"
    if (!this.isStarted(lin))
        lin = this.validFrom;

    if (this.parent != null)
        return this.parent.nextAllowedRunAfter(lin);

    CheckInfo ci = new CheckInfo();
    ci.setWhen(lin);/*from  w  ww .j  ava 2 s .  c om*/

    LocalTime nt = null;

    // move forward 1 day at a time till we find a date that has an opening
    while (true) {
        // if there are any months, those take precedence over other
        if (this.monthly.size() > 0) {
            for (MonthWindow ww : this.monthly)
                if (ww.appliesTo(ci)) {
                    nt = ww.nextTimeOn(ci);
                    break;
                }
        }
        // if there are any weeks, those take precedence over daily
        else if (this.weekly.size() > 0) {
            for (WeekdayWindow ww : this.weekly)
                if (ww.appliesTo(ci)) {
                    nt = ww.nextTimeOn(ci);
                    break;
                }
        } else
            nt = this.dailyWindow.nextTimeOn(ci.getWhen());

        if (nt != null)
            break;

        ci.incrementDay();

        // there is no next allowed
        if (this.isEnded(ci.getWhen()))
            return null;
    }

    lin = TimeUtil.withTime(ci.getWhen(), nt);

    // there is no next allowed
    if (this.isEnded(lin))
        return null;

    return lin;
}

From source file:dk.dma.epd.common.prototype.gui.nogo.NogoDialogCommon.java

License:Apache License

private void calculateSlices() {

    if (useSlices) {

        sliceCount = 1;//from   ww w.j  ava  2 s . c o m

        DateTime startDate = new DateTime(spinnerTimeStart.getValue());
        DateTime endDate = new DateTime(spinnerTimeEnd.getValue());

        DateTime currentVal = startDate.plusMinutes(sliceInMinutes);

        while (currentVal.isBefore(endDate)) {
            startDate = currentVal;
            currentVal = startDate.plusMinutes(sliceInMinutes);
            sliceCount = sliceCount + 1;
        }

        slicesCount.setText("Time Slices: " + sliceCount);
    }
}

From source file:dk.dma.epd.common.prototype.nogo.NogoHandlerCommon.java

License:Apache License

public synchronized void updateNogo(boolean useSlices, int minutesBetween) {

    nogoData = new ArrayList<NoGoDataEntry>();
    // New Request - determine how many time slices are needed to complete the request or if we even need to do slices

    // Calculate slices
    if (this.useSlices) {

        DateTime startDate = new DateTime(validFrom.getTime());
        DateTime endDate = new DateTime(validTo.getTime());

        DateTime currentVal;//from   w w  w  .  j  a va 2  s .  com

        currentVal = startDate.plusMinutes(minutesBetween);

        NoGoDataEntry nogoDataEntry = new NoGoDataEntry(startDate, currentVal);
        nogoData.add(nogoDataEntry);

        while (currentVal.isBefore(endDate)) {
            startDate = currentVal;
            currentVal = startDate.plusMinutes(minutesBetween);
            nogoDataEntry = new NoGoDataEntry(startDate, currentVal);
            nogoData.add(nogoDataEntry);
        }

        nogoLayer.initializeNoGoStorage(nogoData.size());
    } else {
        // Do a single request

        DateTime startDate = new DateTime(validFrom.getTime());
        DateTime endDate = new DateTime(validTo.getTime());

        NoGoDataEntry nogoDataEntry = new NoGoDataEntry(startDate, endDate);
        nogoData.add(nogoDataEntry);
    }

    NoGoWorker nogoWorker = createWorker(nogoData.size(), new DateTime(validFrom.getTime()),
            new DateTime(validTo.getTime()));

    nogoWorker.start();

}

From source file:dk.dma.epd.common.prototype.service.IntendedRouteHandlerCommon.java

License:Apache License

/**
 * Finds the TCPA for two routes and returns the corresponding {@linkplain FilteredIntendedRoute}.
 * <p>//  w ww .  ja  v  a 2s.  c o m
 * This method is only valid if the current start way point of route 1 is before route 2.
 * 
 * @param route1
 * @param route2
 * @return
 */
protected FilteredIntendedRoute findTCPA(Route route1, Route route2) {

    // Focus on time
    FilteredIntendedRoute filteredIntendedRoute = new FilteredIntendedRoute(getMmsi(route1), getMmsi(route2));

    // We need to check if there's a previous waypoint, ie. we are either
    // starting navigating or are between two waypoints
    // int route1StartWp = route1.getActiveWpIndex();
    // int route2StartWp = route2.getActiveWpIndex();

    int route1StartWp = 0;
    int route2StartWp = 0;

    int route1ActiveWp = 0;

    if (route1 instanceof IntendedRoute) {
        route1StartWp = ((IntendedRoute) route1).getActiveWpIndex();
        route1ActiveWp = ((IntendedRoute) route1).getActiveWpIndex();
    }

    if (route2 instanceof IntendedRoute) {
        route2StartWp = ((IntendedRoute) route2).getActiveWpIndex();

    }

    if (route1 instanceof ActiveRoute) {
        route1StartWp = ((ActiveRoute) route1).getActiveWaypointIndex();
        route1ActiveWp = ((ActiveRoute) route1).getActiveWaypointIndex();
    }

    if (route2 instanceof ActiveRoute) {
        route2StartWp = ((ActiveRoute) route2).getActiveWaypointIndex();

    }

    // if (route1StartWp > 0) {
    // route1StartWp = route1StartWp - 1;
    // }
    //
    // if (route2StartWp > 0) {
    // route2StartWp = route2StartWp - 1;
    // }

    // Should the comparison even be made

    DateTime route1Start = getEta(route1, route1StartWp);
    DateTime route1End = getEta(route1, route1.getEtas().size() - 1);

    DateTime route2Start = getEta(route2, route2StartWp);
    DateTime route2End = getEta(route2, route2.getEtas().size() - 1);

    // The route dates does not overlap, return immediately
    if (route2Start.isAfter(route1End) || route1Start.isAfter(route2End)) {
        LOG.debug("The route dates does not overlap, return immediately");

        LOG.debug("Route 1 Start: " + route1Start + " and end: " + route1End);
        LOG.debug("Route 2 Start: " + route2Start + " and end: " + route2End);

        return filteredIntendedRoute;
    }

    // Find first point in time that they have in common
    if (route1Start.isBefore(route2Start)) {
        // Route1 starts first
        // Thus route2 start must be first common timeslot

        // Find location for both at route2start time
        // route2Start

        // Location for route2 is given from
        Position route2StartPos = route2.getWaypoints().get(route2StartWp).getPos();

        DateTime route1WpStart = null;
        DateTime route1WpEnd;

        boolean foundSegment = false;

        int i;
        for (i = route1ActiveWp; i < route1.getWaypoints().size(); i++) {
            if (i > 0) {
                route1WpStart = getEta(route1, i - 1);
                route1WpEnd = getEta(route1, i);

                if (route1WpStart.isBefore(route2Start) && route1WpEnd.isAfter(route2Start)) {
                    // We have the found the segment we need to start from

                    LOG.debug("Found segment");
                    foundSegment = true;
                    break;
                }
            }
        }

        if (foundSegment) {

            // Now find position at time of route2Start

            LOG.debug("Route 1 WP Start is at " + route1.getEtas().get(i - 1));
            LOG.debug("Route 2 Start is at " + route2.getEtas().get(route2StartWp));

            // How long will we have travelled along our route (route 1)
            long timeTravelledSeconds = (route2Start.getMillis() - route1WpStart.getMillis()) / 1000;

            double speedInLeg = route1.getWaypoints().get(i - 1).getOutLeg().getSpeed();

            LOG.debug("We have travelled for how many minutes " + timeTravelledSeconds / 60 + " at speed "
                    + speedInLeg);

            double distanceTravelled = Calculator.distanceAfterTimeMph(speedInLeg, timeTravelledSeconds);

            LOG.debug("We have travelled " + distanceTravelled + " nautical miles in direction: "
                    + route1.getWaypoints().get(i - 1).calcBrg());

            Position position = Calculator.findPosition(route1.getWaypoints().get(i - 1).getPos(),
                    route1.getWaypoints().get(i - 1).calcBrg(), Converter.nmToMeters(distanceTravelled));

            LOG.debug("Difference start pos" + route1.getWaypoints().get(i - 1).getPos() + " vs " + position);

            LOG.debug("The distance between points is "
                    + Converter.metersToNm(position.distanceTo(route2StartPos, CoordinateSystem.CARTESIAN)));

            // intersectPositions.add(position);
            //
            // intersectPositions.add(route2StartPos);

            // In nautical miles
            // double route1SegmentTraversed = distanceTravelled;
            // double route2SegmentTraversed = 0;

            // Okay so we are in position and in route2StartPos
            // We must start traversing the route now, assume straight
            // lines, for each traversing check the distance between
            // points

            // Adaptive traversing, start with time slots of 10 minutes, if
            // distance between points is smaller than x
            // Or if distance is simply decreasing, reduce time traversing.
            // If the distance becomes below the threshold locate point
            // where it starts

            // Ensure that we do not traverse beyond the length of the route

            // We need to switch segments at some point - wait with that

            Position route1CurrentPosition = position;
            Position route2CurrentPosition = route2StartPos;

            int route1CurrentWaypoint = i - 1;
            int route2CurrentWaypoint = route2StartWp - 1;

            if (route2CurrentWaypoint < 0) {
                route2CurrentWaypoint = 0;
            }

            if (route1CurrentWaypoint < 0) {
                route1CurrentWaypoint = 0;
            }

            DateTime traverseTime = route2Start;

            DateTime route1SegmentEnd = getEta(route1, route1CurrentWaypoint + 1);
            DateTime route2SegmentEnd = getEta(route2, route2CurrentWaypoint + 1);

            while (true) {

                double currentDistance = Converter.metersToNm(
                        route1CurrentPosition.distanceTo(route2CurrentPosition, CoordinateSystem.CARTESIAN));

                if (currentDistance <= ENC_DISTANCE_EPSILON || currentDistance <= ALERT_DISTANCE_EPSILON
                        || currentDistance <= FILTER_DISTANCE_EPSILON) {

                    if (traverseTime.isAfter(PntTime.getDate().getTime())) {

                        IntendedRouteFilterType filterType = IntendedRouteFilterType.FILTERONLY;

                        // Top level filter only, no msg or graphics
                        // if (currentDistance <= FILTER_DISTANCE_EPSILON) {
                        // filterType = IntendedRouteFilterType.FILTERONLY;
                        // }

                        // We want an ENC graphics but no warning
                        if (currentDistance <= ENC_DISTANCE_EPSILON) {
                            filterType = IntendedRouteFilterType.ENC;
                        }

                        // We want an alert
                        if (currentDistance <= ALERT_DISTANCE_EPSILON) {
                            filterType = IntendedRouteFilterType.ALERT;
                        }

                        // We want both
                        if (currentDistance <= ALERT_DISTANCE_EPSILON
                                && currentDistance <= ENC_DISTANCE_EPSILON) {
                            filterType = IntendedRouteFilterType.ALERT;
                        }

                        DecimalFormat df = new DecimalFormat("#.##");

                        IntendedRouteFilterMessage filterMessage = new IntendedRouteFilterMessage(route1,
                                route2, route1CurrentPosition, route2CurrentPosition,
                                "TCPA Warning, proxmity of " + df.format(currentDistance) + " nautical miles ",
                                0, 0, filterType);

                        filterMessage.setTime1(traverseTime);
                        filterMessage.setTime2(traverseTime);

                        filteredIntendedRoute.getFilterMessages().add(filterMessage);
                        LOG.debug("Adding warning");
                    }
                } else {
                    LOG.debug("Found distance of " + currentDistance + " at " + traverseTime);
                }

                // Traverse with a minute
                traverseTime = traverseTime.plusMinutes(1);
                route1CurrentPosition = traverseLine(route1, route1CurrentWaypoint, route1CurrentPosition, 60);
                route2CurrentPosition = traverseLine(route2, route2CurrentWaypoint, route2CurrentPosition, 60);

                if (traverseTime.isAfter(route1SegmentEnd)) {

                    // LOG.debug("We have traversed " +
                    // route1SegmentTraversed + " nautical miles");
                    LOG.debug("We are at waypoint id  " + route1CurrentWaypoint
                            + " and the route has a total of " + route1.getWaypoints().size() + " waypoints");
                    // We are done with current leg, is there a next one?

                    // No more waypoints - terminate zero indexing and last
                    // waypoint does not have an out leg thus -2
                    if (route1CurrentWaypoint >= route1.getWaypoints().size() - 2) {
                        LOG.debug("We are breaking - route 1 is done");
                        break;
                    } else {
                        LOG.debug("SWITCHING LEG FOR ROUTE 1, current bearing is ");
                        // Switch to next leg
                        route1CurrentWaypoint++;

                        LOG.debug("We are now at waypoint " + route1CurrentWaypoint);

                        // Traverse a bit
                        int missingSecs = (int) (traverseTime.toDate().getTime()
                                - route1SegmentEnd.toDate().getTime()) / 1000;
                        route1CurrentPosition = traverseLine(route1, route1CurrentWaypoint,
                                route1.getWaypoints().get(route1CurrentWaypoint).getPos(), missingSecs);

                        route1SegmentEnd = getEta(route1, route1CurrentWaypoint + 1);

                        // Skip to next WP start traverse
                        // traverseTime = new
                        // DateTime(route1.getEtas().get(route1CurrentWaypoint));
                    }
                }

                // if (route2SegmentTraversed >
                // Converter.milesToNM(route2.getWaypoints().get(route2CurrentWaypoint).calcRng()))
                // {
                if (traverseTime.isAfter(route2SegmentEnd)) {

                    // LOG.debug("ROUTE 2: We have traversed " +
                    // route2SegmentTraversed + " nautical miles out of "
                    // +
                    // Converter.milesToNM(route2.getWaypoints().get(route2CurrentWaypoint).calcRng()));
                    LOG.debug("We are at waypoint id  " + route2CurrentWaypoint
                            + " and the route has a total of " + route2.getWaypoints().size() + " waypoints");

                    // No more waypoints - terminate
                    if (route2CurrentWaypoint >= route2.getWaypoints().size() - 2) {
                        LOG.debug("We are breaking - route 2 is done");
                        break;
                    } else {
                        LOG.debug("SWITCHING LEG FOR ROUTE 1");

                        // Switch to next leg
                        route2CurrentWaypoint++;

                        int missingSecs = (int) (traverseTime.toDate().getTime()
                                - route2SegmentEnd.toDate().getTime()) / 1000;
                        route2CurrentPosition = traverseLine(route2, route2CurrentWaypoint,
                                route2.getWaypoints().get(route2CurrentWaypoint).getPos(), missingSecs);

                        route2SegmentEnd = getEta(route2, route2CurrentWaypoint + 1);

                        // Skip to next WP start traverse
                        // traverseTime = new
                        // DateTime(route2.getEtas().get(route2CurrentWaypoint));
                    }

                }

                // Are we more than x hours in the future then stop
                DateTime currentTime = new DateTime(PntTime.getDate().getTime());

                if (traverseTime.isAfter(currentTime.plusHours(3))) {
                    LOG.debug("More than 3 hours head of current time, ending checks");
                    break;
                }

            }
        } else {
            LOG.debug("No segment was found - not sure how we reached this point...");
        }

    } else {
        // Route2 starts first
        // Thus route1 start must be first common timeslot

    }

    // findPosition(Position startingLocation, Position endLocation, double
    // distanceTravelled){

    return filteredIntendedRoute;
}

From source file:dk.itst.oiosaml.trust.OIOSoapEnvelope.java

License:Mozilla Public License

/**
 * Add a timestamp to the Security header.
 * @param timestampSkew How many minutes before the message should expire.
 *///w ww.ja v  a2s.co m
public void setTimestamp(int timestampSkew) {
    DateTime now = new DateTime().toDateTime(DateTimeZone.UTC);

    Timestamp timestamp = SAMLUtil.buildXMLObject(Timestamp.class);
    Created created = SAMLUtil.buildXMLObject(Created.class);
    created.setDateTime(now.minusMinutes(timestampSkew));
    timestamp.setCreated(created);

    Expires exp = SAMLUtil.buildXMLObject(Expires.class);
    exp.setDateTime(now.plusMinutes(timestampSkew));
    timestamp.setExpires(exp);

    security.getUnknownXMLObjects().add(timestamp);
    addSignatureElement(timestamp);
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean conflicts(DateTime bookedTime, DateTime time) {
    boolean conflicts = false;

    // On the same date
    if (bookedTime.toDateMidnight().equals(time.toDateMidnight())) {
        bookedTime = DateUtils.resetDateTime(bookedTime, time);
        time = DateUtils.resetDateTime(time, time);

        DateTime st = bookedTime.minusMinutes(lessonDuration);
        DateTime et = bookedTime.plusMinutes(lessonDuration);

        Interval bookedInterval = new Interval(st, et);

        if (bookedInterval.contains(time) && st.equals(time) == false) {
            conflicts = true;/*from  ww w.ja  va 2  s .c o  m*/
        }
    }

    return conflicts;
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean inLesson(DateTime bookedTime, DateTime time) {
    boolean inLesson = false;

    // On the same date
    if (bookedTime.toDateMidnight().equals(time.toDateMidnight())) {
        bookedTime = DateUtils.resetDateTime(bookedTime, time);
        time = DateUtils.resetDateTime(time, time);

        DateTime et = bookedTime.plusMinutes(lessonDuration);

        Interval bookedInterval = new Interval(bookedTime, et);

        if (bookedInterval.contains(time) && bookedTime.equals(time) == false) {
            inLesson = true;//from w w  w  .j  a  v a  2 s .c o  m
        }
    }

    return inLesson;
}

From source file:dk.teachus.backend.testdatagenerator.DynamicDataImport.java

License:Apache License

private void createBookings(Teacher teacher, DateMidnight startDate, DateMidnight endDate) {
    Session session = sessionFactory.openSession();
    session.beginTransaction();// w  w  w .  j a  va  2s .  c  o  m

    Set<DateTime> bookedDates = new HashSet<DateTime>();

    List<Pupil> pupils = getPupils(teacher, session);
    List<Period> periods = getPeriods(teacher, session);

    DateTime now = new DateTime();

    for (Pupil pupil : pupils) {
        DateMidnight date = startDate;
        while (date.isBefore(endDate)) {
            // First see if the pupil should have a booking here at all
            long shouldBook = Math.round(Math.random());
            if (shouldBook == 1) {
                // Then find out which period to book in
                int periodIndex = (int) (Math.random() * periods.size());
                Period period = periods.get(periodIndex);
                log.debug("Booking lesson for period: " + period.getName());

                // Then find out which day in the period to book in
                int weekDayIndex = (int) (Math.random() * period.getWeekDays().size());
                WeekDay weekDay = period.getWeekDays().get(weekDayIndex);
                DateMidnight weekDayDate = date.withDayOfWeek(weekDay.getYodaWeekDay());

                // Now find out which time of day to use
                // We do that by listing the possible booking time entries. A lesson doesn't have to start at a whole number.
                List<DateTime> avaiableLessonsStart = new ArrayList<DateTime>();
                DateTime bookTime = period.getStartTime().toDateTime(weekDayDate);
                DateTime et = period.getEndTime().toDateTime(weekDayDate);
                while (bookTime.isBefore(et)) {
                    if (period.mayBook(bookTime)) {
                        avaiableLessonsStart.add(bookTime);
                    }

                    bookTime = bookTime.plusMinutes(period.getIntervalBetweenLessonStart());
                }

                int selectedIndex = (int) Math.round(Math.random() * (avaiableLessonsStart.size() - 1));
                log.debug("Selected lesson number " + selectedIndex + " out of " + avaiableLessonsStart.size());
                bookTime = avaiableLessonsStart.get(selectedIndex);

                if (bookedDates.contains(bookTime) == false) {
                    bookedDates.add(bookTime);

                    // Create booking
                    PupilBooking booking = new PupilBookingImpl();
                    booking.setCreateDate(new DateTime());
                    booking.setDate(bookTime);
                    booking.setPeriod(period);
                    booking.setTeacher(teacher);
                    booking.setPupil(pupil);
                    booking.setNotificationSent(true);
                    booking.setPupilNotificationSent(true);

                    // Set the paid based on the booking time is in the past
                    if (now.isAfter(bookTime)) {
                        // If it's within a month, then give it a 40% change of not have been paid
                        if (now.minusMonths(1).isBefore(bookTime)) {
                            int pct = (int) (Math.random() * 100.0);
                            if (pct >= 40) {
                                booking.setPaid(true);
                            }
                        } else {
                            booking.setPaid(true);
                        }
                    }

                    // Book
                    session.save(booking);
                }
            }

            date = date.plusWeeks(1);
        }
    }

    session.getTransaction().commit();
    session.close();
}

From source file:dk.teachus.frontend.components.calendar.PeriodsCalendarPanel.java

License:Apache License

@Override
protected IModel<List<TimeSlot<PeriodBookingTimeSlotPayload>>> getTimeSlotModel(final DateMidnight date) {
    return new AbstractReadOnlyModel<List<TimeSlot<PeriodBookingTimeSlotPayload>>>() {
        private static final long serialVersionUID = 1L;

        @Override/* w  w w .  j  ava2 s.  c om*/
        public List<TimeSlot<PeriodBookingTimeSlotPayload>> getObject() {
            List<TimeSlot<PeriodBookingTimeSlotPayload>> timeSlots = new ArrayList<TimeSlot<PeriodBookingTimeSlotPayload>>();
            List<DatePeriod> periods = datePeriodsModel.getObject();
            DatePeriod currentDatePeriod = null;
            for (DatePeriod datePeriod : periods) {
                if (datePeriod.getDate().equals(date)) {
                    currentDatePeriod = datePeriod;
                    break;
                }
            }

            if (currentDatePeriod != null) {
                List<Period> periodsList = currentDatePeriod.getPeriods();
                for (Period period : periodsList) {
                    DateTime startTime = period.getStartTime().toDateTime(date);
                    DateTime endTime = period.getEndTime().toDateTime(date);

                    DateTime time = startTime;
                    while (time.isBefore(endTime)) {
                        /*
                         * Booking
                         */
                        Bookings bookings = bookingsModel.getObject();
                        Booking booking = bookings.getBooking(period, time);

                        PeriodBookingTimeSlotPayload payload = new PeriodBookingTimeSlotPayload();
                        payload.setPeriod(period);
                        payload.setBooking(booking);

                        timeSlots.add(new TimeSlot<PeriodBookingTimeSlotPayload>(time.toLocalTime(),
                                time.toLocalTime().plusMinutes(period.getLessonDuration()), payload));

                        time = time.plusMinutes(period.getIntervalBetweenLessonStart());
                    }
                }
            }

            return timeSlots;
        }

        @Override
        public void detach() {
            datePeriodsModel.detach();
            bookingsModel.detach();
        }
    };
}