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

Weekly rule misbehaving in 0.16.0 #387

Closed
ianloblaw opened this issue Apr 19, 2017 · 3 comments
Closed

Weekly rule misbehaving in 0.16.0 #387

ianloblaw opened this issue Apr 19, 2017 · 3 comments
Assignees
Labels

Comments

@ianloblaw
Copy link

Hi, after upgrading to 0.16.0 from 0.15.0 some failures have been introduced to unit tests for the module that we have used ice_cube for.

Ruby version: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

Given the following IceCube::Schedule:
{ :start_time => { :time => 2009-11-02 12:00:00 UTC, :zone => "America/Montreal" }, :end_time => { :time => 2009-11-02 13:15:00 UTC, :zone => "America/Montreal" }, :rrules => [ [0] { :validations => { :day => [ [0] 1, [1] 2 ] }, :rule_type => "IceCube::WeeklyRule", :interval => 3, :week_start => 0 } ], :rtimes => [], :extimes => [] }

The schedule should occur on

Mon, 02 Nov 2009 07:00:00 EST -05:00,
Tue, 03 Nov 2009 07:00:00 EST -05:00,
Mon, 23 Nov 2009 07:00:00 EST -05:00,
Tue, 24 Nov 2009 07:00:00 EST -05:00,
Mon, 14 Dec 2009 07:00:00 EST -05:00,
Tue, 15 Dec 2009 07:00:00 EST -05:00,
Mon, 04 Jan 2010 07:00:00 EST -05:00,
Tue, 05 Jan 2010 07:00:00 EST -05:00,
etc

However calling .next_occurrences(3, Time.utc(2009, 12, 28, 12)) on the schedule yields

[0] Tue, 29 Dec 2009 07:00:00 EST -05:00,
[1] Mon, 04 Jan 2010 07:00:00 EST -05:00,
[2] Tue, 05 Jan 2010 07:00:00 EST -05:00

Notice the schedule erroneously indicates it will occur on Tue, 29 Dec in this case.

@avit
Copy link
Collaborator

avit commented Apr 19, 2017

I corrected some issues surrounding weekly intervals, specifically around the first occurrences getting missed based on the start time not being aligned to the start of the week.

   November 2009
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

It looks like you are requesting the next 3 occurrences from a time before the start time. That should not be possible, and I'm guessing the alignment is thrown off... Based on your rule, weekday 1 and 2 should be Monday 2nd and Tuesday 3rd just as you expect.

I'll have a look and get a fixed release out soon, with a test for this scenario. Thanks for the report!

@avit avit added the bug label Apr 19, 2017
@avit avit self-assigned this Apr 19, 2017
@avit avit closed this as completed in #389 Apr 23, 2017
avit added a commit that referenced this issue Apr 23, 2017
@jopotts
Copy link
Contributor

jopotts commented May 3, 2017

Can we have a version bump for this fix please? Thanks!

@seejohnrun
Copy link
Collaborator

@jopotts just cut 0.16.1 - thanks!

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

4 participants