val cronExp = "0 0 2 ? * *"
val Right(cron) = Cron(cronExp)
val Some(previous) = cron.prev(new DateTime())
val Some(previousPrevious) = cron.prev(previous)
val atBadDate = ZonedDateTime.parse("2017-06-30T23:30:45.123Z")
val Right(cron) = Cron("4 31 4 ? * *")
val next = cron.next(atBadDate)
val atGoodDate = ZonedDateTime.parse("2017-06-30T00:30:45.123Z")
val Right(cron) = Cron("4 31 4 ? * *")
val next = cron.next(atGoodDate)
atBadDate
being earlier than midnight, the cron expression thinks it needs to advance the time from hour 23
to hour 4
1
towards the next date field, which is DayOfMonth
30
) it tries to assing the day 31
to the month of June (6
), which is an invalid date and fails returning a None
val atBadDate = java.time.LocalDate.parse("2017-06-30")
val Right(cron) = Cron("4 31 4 ? * *")
val next = cron.next(atBadDate)
assert(next.nonEmpty)
scala> val next = cron.datePart.next(atBadDate)
next: Option[java.time.LocalDate] = Some(2017-07-01)
LocalDate
does not support updates in time fields
LocalDateTime
from the LocalDate
LocalTime
and LocalDate
...