question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next() yields a time in the past

See original GitHub issue

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")
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rvdwendencommented, Apr 13, 2017

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

1reaction
alonsodomincommented, Apr 9, 2017

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Behaviour of Python's "yield" - Stack Overflow
The next time .next() is called, the function execution is resumed until the next yield , etc. until the function returns something.
Read more >
33 - Generator Functions ( yield; next ) | Python Tutorials
Generators are iterators that calculate and return a value and then wait for you to call them again with the next() function.
Read more >
Python Generators - Programiz
So we can iterate through the items using next() . Once the function yields, the function is paused and the control is transferred...
Read more >
How to Use Generators and Yield in Python | CBT Nuggets
This is done by using the generator method called __next()__. (That is two underscores before and after "next()".
Read more >
Asynchronous Iterators in JavaScript | Codementor
The interface of next() returns the tuple { value, done } and the values of value and done need to be known at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found