Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
java.time.ZonedDateTime = 2018-02-18T22:17:17.292Z[Etc/UTC]
override def computeTimes(sunset: LocalTime): Stream[(LocalTime, SchedulingCapacities)] = {
val timesStream =
Stream.iterate(scheduleWeekdayTimes.firstTime.forSunset(sunset))(_ plusMinutes 15)
def loop(scheduleWeekdayTimesSpans: List[ScheduleWeekdayTimesSpan],
times: Stream[LocalTime]): Stream[(LocalTime, SchedulingCapacities)] =
scheduleWeekdayTimesSpans match {
case Nil => Stream.Empty
case span :: spans =>
val repeated = times zip Stream.continually(span.schedulingCapacityies)
val limited = span.untilClosingOf.map(scheduleWeekdayTimes.lastTimes(_)) match {
case None => repeated.take(span.repeatCount)
case Some(stopRepeatTime) => repeated.takeWhile { case (t, _) => !t.isAfter(stopRepeatTime) } // the question relates to this line
}
limited ++ loop(spans, times.drop(limited.length))
}
loop(scheduleWeekdayTimesSpans, timesStream)
}