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

IceCube::Schedule#occurrences_between miss occurrences strictly included in range #497

Open
TruffeCendree opened this issue May 14, 2021 · 2 comments

Comments

@TruffeCendree
Copy link

TruffeCendree commented May 14, 2021

I have a reccurring rule, which should occur on 2021-08-16 08:00:00 +0200.
But calling schedule.occurrences_between with a range strictly including the occurrence returns [].

The following snippet reproduces the issue on version 0.16.3.

serialized = {"rrules"=>
  [{"until"=>{"time"=>"2021-09-30T21:59:00.000Z", "zone"=>"Europe/Paris"},
    "interval"=>2,
    "rule_type"=>"IceCube::WeeklyRule",
    "week_start"=>1,
    "validations"=>{"day"=>[1], "hour_of_day"=>[8], "minute_of_hour"=>[0]}}],
 "rtimes"=>[],
 "extimes"=>[],
 "end_time"=>{"time"=>"2021-06-07T08:45:00.000Z", "zone"=>"Europe/Paris"},
 "start_time"=>{"time"=>"2021-06-07T06:00:00.000Z", "zone"=>"Europe/Paris"}}

schedule = IceCube::Schedule.from_hash(serialized)

# returns [], expected to return ["2021-08-16 08:00:00 +0200 - 2021-08-16 10:45:00 +0200"]
schedule.occurrences_between("2021-08-16 00:00:00 +0200".to_time, "2021-08-17 00:00:00 +0200".to_time)

# returns [], expected to return ["2021-08-16 08:00:00 +0200 - 2021-08-16 10:45:00 +0200"]
schedule.occurrences_between("2021-08-16 00:00:00 +0200".to_time - 1.week, "2021-08-17 00:00:00 +0200".to_time)

# returns ["2021-08-16 08:00:00 +0200 - 2021-08-16 10:45:00 +0200"]
# expected to return ["2021-08-02 08:00:00 +0200 - 2021-08-02 10:45:00 +0200", "2021-08-16 08:00:00 +0200 - 2021-08-16 10:45:00 +0200"]
schedule.occurrences_between("2021-08-16 00:00:00 +0200".to_time - 2.weeks, "2021-08-17 00:00:00 +0200".to_time)

Thanks.

@zernie
Copy link

zernie commented May 27, 2021

Damn, this issue cost me half a day. I have to substract 1s from time_end to make it work

@TruffeCendree
Copy link
Author

In our case, we got it working by removing hour_of_day and minute_of_hour from validations.
start_time must be aligned with hours and minutes we want.

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

2 participants