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

Support Recurring event #62

Closed
tuyen-vuduc opened this issue Feb 19, 2021 · 1 comment
Closed

Support Recurring event #62

tuyen-vuduc opened this issue Feb 19, 2021 · 1 comment
Labels
T: Feat Type: :tada: New Features

Comments

@tuyen-vuduc
Copy link

Hi,

Recurring event is very popular in our life.

Do we have any plan to support this?

@tuyen-vuduc tuyen-vuduc added the T: Feat Type: :tada: New Features label Feb 19, 2021
@JonasWanke
Copy link
Owner

Supporting recurring events in Timetable directly is out of scope. You can, however, use my package rrule to calculate occurrences of recurring events in a given time frame using recurrenceRule.getAllInstances(…), and then wrap each occurrence in its own event that is returned to Timetable. (It might make sense to cache the calculated occurrences using recurrenceRule.shouldCacheResults.)

For example, using the new 1.0.0 pre-releases of Timetable, you could do something like this (not tested):

return TimetableConfig<BasicEvent>(
  eventProvider: (interval) {
    return myEvents.expand((event) {
      // For each recurring event, we calculate all instances that intersect the requested interval:
      final instances = event.recurrenceRule.getAllInstances(
        start: event.start - event.duration,
        after: interval.start,
        includeAfter: true,
        before: interval.end,
        includeBefore: true,
      );
      // From each instance, we create a separate event for Timetable:
      return instances.map((it) => event.copyWith(
            id: '${event.id}-$it',
            start: it,
            end: it + event.duration,
          ));
    });
  },
  // Other properties…
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Feat Type: :tada: New Features
Projects
None yet
Development

No branches or pull requests

2 participants