public Duration calcRest() {

        Duration gap = intervals.findGap(period, rest);

        if (gap == null) {
            gap = intervals.lastGap();
        }

        if (gap.isShorterThan(rest)) {
            return rest.minus(gap);
        } else {
            return new Duration(0);
        }
    }