Coder Social home page Coder Social logo

Support Recurring event about timetable HOT 1 CLOSED

jonaswanke avatar jonaswanke commented on June 22, 2024 2
Support Recurring event

from timetable.

Comments (1)

JonasWanke avatar JonasWanke commented on June 22, 2024 2

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…
);

from timetable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.