Closed martinstreicher closed 3 years ago
@martinstreicher Thanks for the suggestions. Feel free to start a PR if you're able/interested in adding these features.
I am working with this code on a project, so I can likely put up a PR shortly.
Closing for now. Feel free to open if you're still actively working on this.
I am posting this to collect thoughts and perhaps learn of approaches using the current code.
I see that
.include?
is a way to determine if a timestamp (instance ofTime
) is included in a schedule. That's useful, but it's making very fine-grained comparisons to yield a match.I would like to have the following methods:
Schedule#occuring_on?(Date(yyyy, mm, dd)
: This method would ignore the timestamp and compare only by date.For example,
schedule.occurring_on?(Date.new(2019, 9, 1))
is true if Sept 1, 2019 is among the dates in the schedule. (I know I can implement this by converting an occurrence to aDate
and then looking for matches using a variety of techniques (date ranges, set intersection, etc.) It would be nice to have this as a convenience: the occurrences would be converted to dates and the argument would be converted to aDate
. It might be nice to have a corollaryoccurring_on?
on the recurrence model itself.To have parity with
occurring_on?
, offeroccurring_at?
onSchedule
andMontrose
to answer if a given time stamp is captured by the schedule or recurrence rule, respectively..after(Date/Time)
yields the next occurrence after the given date or timestamp..before
would do the same thing before the point in time.I am sure there are other conveniences for comparing, such as whether a calendar includes any of the times, all of the times, none of the the times.