Closed meghana-viswanath closed 6 years ago
@alonsodomin am I right in thinking that https://github.com/alonsodomin/cron4s/issues/80 fixes this?
hi @graingert, you are right, it's exactly the same issue which was already solved. This is what I get in a REPL using 0.4.3
scala>
import cron4s._
import java.time._
import cron4s.lib.javatime._
scala> val cron = Cron.unsafeParse("0 0 0 30 3,6,9,12 ?")
cron: cron4s.expr.CronExpr = 0 0 0 30 3,6,9,12 ?
scala> val date = LocalDate.of(2017, 2, 14).atStartOfDay()
date: java.time.LocalDateTime = 2017-02-14T00:00
scala> cron.next(date)
res0: Option[java.time.LocalDateTime] = Some(2017-03-30T00:00)
@meghana-viswanath What version of Cron4s are your using?
Hi @alonsodomin, I tried with the latest version 0.4.3 but I am using cron4s-joda not the core
@meghana-viswanath are you sure you are using 0.4.3? This is what I get when using Joda in the REPL:
scala> val cron = Cron.unsafeParse("0 0 0 30 3,6,9,12 ?")
cron: cron4s.expr.CronExpr = 0 0 0 30 3,6,9,12 ?
scala> val date = new LocalDate(2017, 2, 14).toDateTimeAtCurrentTime()
date: org.joda.time.DateTime = 2017-02-14T12:45:05.596Z
scala> cron.next(date)
res0: Option[org.joda.time.DateTime] = Some(2017-03-30T00:00:00.000+01:00)
It would be weird (and worth looking at) if it were different. Basically the same test battery is run against all the supported libraries...
For a cron expression of the following type -
"0 0 0 30 3,6,9,12 ?"
, thenext
function for a date in February returns a None. Changing the expression to include a common day across all months such as 28, works.Cron("0 0 0 30 3,6,9,12 ?").right.next(DateTime.now.withMonthOfYear(2))
returns None