Skip to content

A javascript recurrence library #457

Closed

Description

@jorroll

When I first started using ice_cube to handle recurring dates, maybe a year+ ago, I wasn't sure how I could also handle recurrence information on the client side. I use rails in api mode to power an Angular application, so the recurring_select gem mentioned in the readme wasn't a good choice.

After some hunting, I found rrulejs, which was pretty nice but, at that time, poorly maintained and buggy. It also didn't support time zones and breaks the ical spec in a few places, and I had to patch ice_cube to work with it. Obviously not ideal (though in the past month one community member has stepped up and fixed most all of these problems).

So I ended up making my own javascript (typescript) recurrence library that supports the ICAL spec and can communicate to/from ice_cube via ICAL strings. You can check it out over at rSchedule. It works very well with ice_cube.

rSchedule has full timezone support (depending on what javascript date library you're using with it), so I've paired it with the ice_cube timezone branch in #455, though that isn't necessary if someone doesn't care about timezone support.

Anyway, thanks so much for building and maintaining ice_cube for all this time!!! Having build rSchedule, I know how incredibly time consuming that must have been...

For anyone interested in using ice_cube with a (javascript / typescript) client side app, I'd recommend checking out rSchedule, as just sending down a schedule's ICAL string and iterating the dates on the client side is much less data intensive then sending individual dates to the client from the server.

rSchedule supports RRULE, EXRULE, RDATE, and EXDATEs.

Example rSchedule usage with ice_cube

Server side

ical_string = schedule.to_ical

client side

const schedule = Schedule.fromICal(ical_string, StandardDateAdapter)

for (const date of schedule.occurrences()) {
  // do stuff
}

schedule.occursOn({date: new Date()}) // boolean

schedule.occursOn({weekday: 'TU'}) // boolean

schedule.occurrences({start: new Date(), take: 10}).toArray().map(date => date.toISOString())

Check out the rSchedule repo for more info

ps: I called out ice_cube as inspiration at the end of the project's README :)

Activity

  1. taylorbrooks commented on Sep 5, 2018

    @taylorbrooks

    @thefliik rSchedule looks cool. Is there a demo site that shows off the UI?

    I'd love to look at other alternatives to recurring_select.

  2. jorroll commented on Sep 5, 2018

    @jorroll
    ContributorAuthor

    @taylorbrooks rSchedule has no UI, it's purely a library for the logic. In this respect it is like ice_cube, except the processing happens on the client side.

    In my case, I use it with angular-calendar on the client side (which supplies the UI), but there are other calendar libraries like full-calendar (plain javascript) that you can use it with (and I'm sure ones for React and Vue). Neither angular-calendar nor full-calendar provide any recurring logic (they are just UI), so you need to pair them with some sort of library like rSchedule (if you want to handle recurring dates).

    I haven't made a demo site for rSchedule, but it has a wiki site that explains how to use it and shows off the API.

  3. jorroll commented on Sep 11, 2018

    @jorroll
    ContributorAuthor

    Btw, feel free to close this at any time @seejohnrun. It was really just meant as an FYI and a thank you for making/maintaining ice_cube :)

  4. seejohnrun commented on Sep 24, 2018

    @seejohnrun
    Collaborator

    Awesome - thanks for the heads up @thefliik this looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions