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

previous_occurrence misses if occurrence not a full day behind #442

Open
jachenry opened this issue Jun 10, 2018 · 1 comment
Open

previous_occurrence misses if occurrence not a full day behind #442

jachenry opened this issue Jun 10, 2018 · 1 comment
Labels

Comments

@jachenry
Copy link

I am attempting to use previous_occurrence() with a date that is 1ms in front of the first occurrence but it does not detect it. It's almost like previous_occurrence only finds occurrences that are at least 1 day behind. Is there a way to allow previous_occurrence to evaluate based on time rather than just date?

Below is an example showing how the first occurrence is due at 11:59pm on dec 31st but checking for previous occurrences from jan 1 doesn't find it.

  schedule = IceCube::Schedule.new(Date.parse('01-01-2018').end_of_day - 1.day) do |s|
    s.add_recurrence_rule(IceCube::Rule.monthly(6))
  end
  schedule.first # Sun, 31 Dec 2017 23:59:59 UTC +00:00
  schedule.previous_occurrence(Date.parse('01-01-2018')) # nil
@avit
Copy link
Collaborator

avit commented Aug 1, 2018

The smallest unit that IceCube works with is 1 second: milliseconds are dropped.

I think here because you are trying to jump from 00:00:00 to the previous occurrence at 23:59:59.99999, it's jumping back to 23:59:59 which is before the range of the schedule.

I think we are not normalizing the start time when we check that boundary: looks like an edge case.

@avit avit added the bug label Aug 1, 2018
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

2 participants