cronish icon indicating copy to clipboard operation
cronish copied to clipboard

Incorrect calculation of nextTime

Open jgjay opened this issue 11 years ago • 3 comments

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.

jgjay avatar Jun 10 '13 16:06 jgjay

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

philcali avatar Jun 24 '13 17:06 philcali

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.

federico-pellegatta avatar Sep 26 '16 07:09 federico-pellegatta

fixed by #20 but still not release

lielran avatar Nov 12 '16 17:11 lielran