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

exception_times not used on next_occurence #83

Closed
bitboxer opened this issue May 27, 2012 · 6 comments
Closed

exception_times not used on next_occurence #83

bitboxer opened this issue May 27, 2012 · 6 comments
Labels

Comments

@bitboxer
Copy link

Somehow the exception_times is not correctly used in next_occurence creation.

In our software we have:

schedule.exception_times
=> [Sun, 27 May 2012 19:00:00 CEST +02:00]

And this is the result of next_occurence on that element:

schedule.next_occurrences(12)
=> [2012-05-27 19:00:00 +0200, 2012-06-21 19:00:00 +0200, 2012-06-24 19:00:00 +0200, 2012-07-19 19:00:00 +0200, 2012-07-29 19:00:00 +0200, 2012-08-16 19:00:00 +0200, 2012-08-26 19:00:00 +0200, 2012-09-20 19:00:00 +0200, 2012-09-30 19:00:00 +0200, 2012-10-18 19:00:00 +0200, 2012-10-28 19:00:00 +0100, 2012-11-15 19:00:00 +0100]

The first Item should not be there.

@romaind
Copy link

romaind commented Jun 13, 2012

I had the same issue.
It's a .round problem on your time. It seems it can't compare times if one has milliseconds and the other one don't.

All this depends on the format of the start_time of you schedule I guess.

So now, I go with schedule.next_occurences(12, Time.zone.now.round) and it works

@bitboxer
Copy link
Author

Yes, but this should be fixed in ice_cube. I have a workaround in place for that.

@seejohnrun
Copy link
Collaborator

Fix will go out with v0.9.0 - thanks!

@bitboxer
Copy link
Author

Are you sure that this is fixed? I removed the workaround I introduced to our codebase and tried 0.9.1, but it failed. Our current work around is not to use the miliseconds part of the timestamp and check against the exclude list manually.

Basically what we did was:

schedule.next_occurrences(12).each do |occurrence|
    # TODO: Hot-Fix for ice_cube's issue #83
    occurrence = occurrence.without_ms

    if !schedule.extimes.map(&:to_i).include? occurrence.to_i
       # Okay, the occurrence is not in our extimes list
    end
 end

and without_ms is a method on the Time class that creates a copy of the Time object with ms = 0

@seejohnrun
Copy link
Collaborator

Ah - I see the issue you're running into - there will be a fix for this in 0.9.2 - I'll reopen now and add some more detail tonight

@seejohnrun seejohnrun reopened this Oct 20, 2012
@bitboxer
Copy link
Author

Any update on this?

@avit avit closed this as completed in 8ba3fdd Dec 21, 2012
rlivsey pushed a commit to rlivsey/ice_cube that referenced this issue Jun 18, 2013
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