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

Inconsistent daily schedule with interval behaviour between version 0.16.3 and 0.16.4 #514

Open
unrooty-infinum opened this issue Oct 27, 2021 · 3 comments · May be fixed by #515
Open

Inconsistent daily schedule with interval behaviour between version 0.16.3 and 0.16.4 #514

unrooty-infinum opened this issue Oct 27, 2021 · 3 comments · May be fixed by #515
Labels

Comments

@unrooty-infinum
Copy link

Hello! First of all thanks for the gem, you did a great job!

I'm facing an issue with daily schedule with interval after ice_cube update from version 0.16.3 to version 0.16.4.

According the following reproducion scripts you can see that version 0.16.3 output differs from version 0.16.4 output.

Is it expected behaviour? And which version output is correct?

Environment

Ruby: 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
OS: MacOS Big Sur 11.6

Version 0.16.3 behaviour reproducion script

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'ice_cube', '0.16.3'
end

require 'ice_cube'

interval = 4

rule = IceCube::Rule.daily(interval).hour_of_day(9).minute_of_hour(0).second_of_minute(0)

start_time = Time.new(2021, 3, 28, 10, 0, 0, 'UTC') # 2021-03-28 10:00:00 UTC
end_time = Time.new(2021, 4, 7, 23, 59, 59, 'UTC') # 2021-04-07 23:59:59 UTC

schedule = IceCube::Schedule.new(start_time) { |s| s.add_recurrence_rule(rule) }

schedule.occurrences(end_time)

# Output
# 2021-03-29 09:00:00 UTC
# 2021-04-02 09:00:00 UTC
# 2021-04-06 09:00:00 UTC

Version 0.16.4 behaviour reproducion script

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'ice_cube', '0.16.4'
end

require 'ice_cube'

interval = 4

rule = IceCube::Rule.daily(interval).hour_of_day(9).minute_of_hour(0).second_of_minute(0)

start_time = Time.new(2021, 3, 28, 10, 0, 0, 'UTC') # 2021-03-28 10:00:00 UTC
end_time = Time.new(2021, 4, 7, 23, 59, 59, 'UTC') # 2021-04-07 23:59:59 UTC

schedule = IceCube::Schedule.new(start_time) { |s| s.add_recurrence_rule(rule) }

schedule.occurrences(end_time)

# Output
# 2021-04-01 09:00:00 UTC
# 2021-04-05 09:00:00 UTC
@pacso
Copy link
Collaborator

pacso commented Oct 28, 2021

Hey, thanks for getting in touch.

Funnily enough, you've picked the day that clocks change. There was a bug previously that meant that schedules around the clock-change days were incorrectly calculated. This was fixed in the latest release.

Since your schedule starts after the occurrence rule, you don't see the event from the 28th March, but you do see them from the 1st April onwards. The previous behaviour of one existing on the 29th was a bug which is now fixed. The behaviour you see in 0.16.4 is what I would expect.

If I've misunderstood something and you're expecting some different behaviour, then please let me know and we'll investigate further.

@pacso
Copy link
Collaborator

pacso commented Oct 28, 2021

@unrooty-infinum - after chatting to @seejohnrun about it, we agree that this behaviour isn't right.

Interestingly, if you're not using the daily(4) interval, it starts the first occurrence on the right date/time. Will open a PR to resolve it.

@pacso pacso added the bug label Oct 28, 2021
@unrooty-infinum
Copy link
Author

unrooty-infinum commented Oct 28, 2021

@pacso sorry, missed your first reply. I guess that 0.16.3 behaviour is correct because my customer would open a task(bug) in other case, hahaha :)

Anyway thanks for the reply! Please let me know if I can help to resolve this issue.

pacso added a commit that referenced this issue Mar 2, 2022
danielricecodes referenced this issue Oct 29, 2022
* Add Ruby 3.1 and Rails 7.0

* Exclude older versions of ruby from rails 7

* Exclude individually

* Switch to YAML.safe_load

* Add time helpers

* require active_support

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

Successfully merging a pull request may close this issue.

2 participants