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

A javascript recurrence library #457

Closed
jorroll opened this issue Sep 4, 2018 · 4 comments
Closed

A javascript recurrence library #457

jorroll opened this issue Sep 4, 2018 · 4 comments

Comments

@jorroll
Copy link
Contributor

jorroll commented Sep 4, 2018

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 :)

@taylorbrooks
Copy link

@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.

@jorroll
Copy link
Contributor Author

jorroll commented Sep 5, 2018

@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.

@jorroll
Copy link
Contributor Author

jorroll commented Sep 11, 2018

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 :)

@seejohnrun
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants