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

Incorrect calculation of nextTime #14

Open
jgjay opened this issue Jun 10, 2013 · 3 comments
Open

Incorrect calculation of nextTime #14

jgjay opened this issue Jun 10, 2013 · 3 comments

Comments

@jgjay
Copy link

jgjay commented Jun 10, 2013

Hi, I'm having this problem with cronish:

scala> val tests = List(
     |       "every day at 17:30 on Monday to Friday",
     |       "every day at 17:30"
     |     ).zipWithIndex.foreach { t =>
     |       val (test, run) = t
     |
     |       val current = Scalendar.now
     |       val millis = test.cron.nextFrom(current)
     |       println("%d (%s): %s" format(run, test, current))
     |       println("%d (%s): %s" format(run, test, Scalendar(current.time + millis)))
     |     }
0 (every day at 17:30 on Monday to Friday): 06/10/2013 17:08:09
0 (every day at 17:30 on Monday to Friday): 06/11/2013 17:30:00
1 (every day at 17:30): 06/10/2013 17:08:09
1 (every day at 17:30): 06/10/2013 17:30:00

Given that 06/10 is a Monday, shouldn't the .nextFrom(current) for the example "0" above actually return 06/10/2013 17:30:00?

If you look at example "1" which doesn't specify a day of the week, it's calculated correctly.

@philcali
Copy link
Owner

Yep, that does look incorrect. Thanks for spotting that.

@federico-pellegatta
Copy link
Contributor

I have traced back the issue to the following line: cron.scala#L193

cal.inWeek(f + 1) > cal should actually be cal.inWeek(f + 1) >= cal in order to consider also the current day as a valid candidate.

@lielran
Copy link

lielran commented Nov 12, 2016

fixed by #20 but still not release

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

No branches or pull requests

4 participants