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

occurrence convenience methods #11

Merged

Conversation

defeated
Copy link
Contributor

@defeated defeated commented Sep 4, 2010

I needed to add a next_occurrence method for a project I'm working on. (but I'm still learning the codebase, so please let me know if there's a better way to implement this!)

thanks!

@seejohnrun
Copy link
Collaborator

Hey!

Sorry for the delayed response - really busy weekend here.
Thanks for the contribution! These methods are definitely a great addition.

  • remaining_occurrences looks great
  • next_occurrence is a little inefficient because we calculate further ahead than we need to. Really next_occurrence_after should be implemented in a way that it walks forward from the schedule's start_date, and breaks at the first occurrence that is after a given time. Then next_occurrence would be next_occurrence_after(Time.now). Maybe even further to implement them all as nth_occurrence_after(1, Time.now)

^^^ For examples of how this would work check out occurrences_between and find_occurrences

I'm going to take your changes as-is, and head back for next_occurrence optimization later (if you want to give it a shot, that'd be sweet too).

Thanks again,
John C

@seejohnrun
Copy link
Collaborator

All merged in - ice_cube 0.5.6
John C :)

dgilperez pushed a commit to dgilperez/ice_cube that referenced this pull request Dec 9, 2014
Test fix + Sentence connector feature
This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants