Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next() yields a time in the past #59

Closed
rvdwenden opened this issue Apr 3, 2017 · 5 comments
Closed

next() yields a time in the past #59

rvdwenden opened this issue Apr 3, 2017 · 5 comments
Labels

Comments

@rvdwenden
Copy link

When executing the next() function on a cron with weekdays we sometimes get None or a localdatetime in the past (same for prev() ...):

import java.time._

import cron4s.lib.javatime._
import cron4s._

object Cron4Spec {
  def main(args: Array[String]): Unit = {
    val Right(cron) = Cron("0 0 0 * * 1-3")

    for (dayOfMonth <- 1 to 30) {
      val from = LocalDateTime.of(2017, 3, dayOfMonth, 2, 0, 0)
      cron.next(from) match {
        case Some(next) =>
          println(s" $from: after ${next.isAfter(from)}")
        case None =>
          println(s"Cannot get next from: $from")
      }

      cron.prev(from) match {
        case Some(prev) =>
          println(s" $from: before ${prev.isBefore(from)}")
        case None =>
          println(s"Cannot get prev from: $from")
      }
    }
  }
}
@rvdwenden
Copy link
Author

produced with version 0.3.1.

@alonsodomin
Copy link
Owner

Thanks for reporting, I'll look at that as that is a weird behaviour

alonsodomin pushed a commit that referenced this issue Apr 8, 2017
@alonsodomin alonsodomin added the bug label Apr 9, 2017
@alonsodomin
Copy link
Owner

This has been fixed in branch 0.3.x and version 0.3.2 released to Maven Central (it may take a while until is mirrorred everywhere).

@rvdwenden
Copy link
Author

Works for us now after fix (0.3.2)!
Thanks for fixing.

@alonsodomin
Copy link
Owner

alonsodomin commented Apr 13, 2017

Thanks for confirming. Beware that #56 is still lurking around but quite hard to fix in 0.3.x as I need to change a bit the internals. I'm sort of close of a cut for 0.4.0 though which will have that fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants