Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    groblochon
    @groblochon
    Hi ! Thanks for your work, but I have some issue with cron4s :
    ```
    val cronExp = "0 0 2 ? * *"
    val Right(cron) = Cron(cronExp)
    val Some(previous) = cron.prev(new DateTime())
    val Some(previousPrevious) = cron.prev(previous)
    This fail because last line return None... Any idea ?
    A. Alonso Dominguez
    @alonsodomin
    @groblochon What is the output of val Some(previous) = cron.prev(new DateTime()) ?
    can you run it in a REPL and paste the output here?
    groblochon
    @groblochon
    2017-06-01T02:00:00.000+02:00 using joda DateTime
    A. Alonso Dominguez
    @alonsodomin
    ok, just a sec...
    groblochon
    @groblochon
    This case seem work :
    val cronExp = "0 0 2 ? * *"
    val Right(cron) = Cron(cronExp)
    val Some(previous) = cron.prev(new DateTime())
    val Some(previousPrevious) = cron.prev(previous.minusHours(3))
    A. Alonso Dominguez
    @alonsodomin
    yep, that’s weird
    looks like a bug
    let me do an additional check, it might be related with a known issue
    groblochon
    @groblochon
    ok, it's specific to jodaTime you think ?
    A. Alonso Dominguez
    @alonsodomin
    mmm, not necessarily if it is what I think it could be
    so I can confirm this is due to a know bug: alonsodomin/cron4s#73
    Joda has it’s part of guiltyness but the bogus behaviour is in the core
    if you want you can add your case to that ticket as a comment, and I will make sure that there is a test case for it
    sorry for landing into that nasty bug
    groblochon
    @groblochon
    It's nothing, thanks for your time !
    Roberto Leibman
    @rleibman
    I'm sure this has been asked thousands of times... why would next return None here:
     val atBadDate = ZonedDateTime.parse("2017-06-30T23:30:45.123Z")
     val Right(cron) = Cron("4 31 4 ? * *")
     val next = cron.next(atBadDate)
    But A value here:
        val atGoodDate = ZonedDateTime.parse("2017-06-30T00:30:45.123Z")
        val Right(cron) = Cron("4 31 4 ? * *")
        val next = cron.next(atGoodDate)
    *Note, both are on the same day of the month (the last day of June) but one is at start of day and the other closer to the end.
    From my reading, the cron says: at 4:31:04, I don't care on what day of the month, every day of the week and every month.
    Roberto Leibman
    @rleibman
    @alonsodomin ?
    A. Alonso Dominguez
    @alonsodomin
    Hi Roberto
    by the looks of it, I think you are hitting issue #73
    in your atBadDate being earlier than midnight, the cron expression thinks it needs to advance the time from hour 23 to hour 4
    which means that it needs to go pass midnight and therefore it brings a carry over factor of 1 towards the next date field, which is DayOfMonth
    when applying such carry over to the current day of the month (30) it tries to assing the day 31 to the month of June (6), which is an invalid date and fails returning a None
    sorry for that, I was meant to have a fix ready a few weeks ago but I´ve been procastinating it a bit
    A. Alonso Dominguez
    @alonsodomin
    your case is slightly different than the one stated in #73, as the valid outcome for your fist snipped should advance the month field to 7
    I believe this is worth it’s own issue, would you mind creating one?