Skip to content

Use with datetimes?  #14

@rmosolgo

Description

@rmosolgo

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions