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

Use with datetimes? #14

Open
rmosolgo opened this issue Sep 12, 2016 · 0 comments
Open

Use with datetimes? #14

rmosolgo opened this issue Sep 12, 2016 · 0 comments

Comments

@rmosolgo
Copy link
Contributor

Oh hi :)

I'm trying to use this gem with repeating events that happen at certain times of day, for example:

  • Union:
    • Every Tuesday from 7pm to 8:30pm
    • Every Thursday from 6:30pm to 8pm

In that case, applying times to the output of this gem is straightforward: if it's a Tuesday, it's 7-8:30, and if it's a Thursday, it's 6:30-8. But in some cases, it's a bit harder:

  • Union:
    • Every first and third Tuesday from 5pm to 6:30pm
    • Every Tuesday from 7pm to 8:30pm
    • Exact date: mm-dd-yyyy (imagine it's a specific first Tuesday) from 3:30pm to 5pm

Now, given a stream of dates, it's a bit harder to match them with times from my own data. I'd have to reimplement a bit of recursion logic to check which Tuesdays are which.

Are you interested in supporting this use case? I can imagine a few things that might work for me (although I didn't read the paper, so forgive me if I'm going off the rails) :

  • Accept starts-at and ends-at times along with various expression, then return Occurrence objects instead of Dates. (Occurrence could duck-type like a Date, which would minimize the impact on current users.)

    {
      weekday_in_month: {
        weekday: 2, 
        count: 1, 
        start_time: [17, 00], # [hours, minutes] ? Or some other object here?
        end_time: [18, 30], 
    }
    # ...
    schedule.next_occurrence # => #<Occurrence @starts_at=#<DateTime ...> @ends_at=#<DateTime ...> >
  • Accept user-defined metadata with expressions, and include that metadata along with occurrence results

    {
      weekday_in_month: {
        weekday: 2, 
        count: 1, 
        metadata: my_application_object,
      }
    }
    # ...
    schedule.next_occurrence # => #<Occurrence @date=#<Date ...>, @metadata=my_application_object >

Perhaps there are other ways to support this use case?

If you're interested in supporting it, I'd be happy to take a crack at some approach that seems good to you, Thanks!

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

1 participant