简体   繁体   中英

Recurring events on a calendar : RFC 5545 Javascript parsing

I need to integrate recurring events into an adapted version of full-calendar that has an added javascript module which allows offline event browsing.

I'm looking for a javascript library that can parse recurring events according to RFC 5545.

I need to be able to list all recurring events that occur between 2 dates (start date and end date), using RRULE and EXDATE and interpreting daily, weekly, monthly and yearly recurrences.

I've spent hours searching for something to no aval, and I don't want to reinvent the wheel....Can anyone please point me in the right direction for an existing javascript parser?

I checked into skyporters rrule_parser and found that it doesn't support all of the rules (particularly, it won't do BYDAY properly). I found a fantastic alternative:

https://github.com/jakubroztocil/rrule

They are actively supporting this library and have a great demo website that shows all of the functionality. You can parse from either 5545 format or plain text (using the nlp extension). It is feature packed and, as far as I can tell, fully functioning.

look into https://github.com/skyporter/rrule_parser .

I hope it will help you.

here is a recurrence widget for jquery, which parses/creates RFC5545 compatible recurrence strings.

https://github.com/collective/jquery.recurrenceinput.js

it does not expanding of a recurrence rule into occurrence dates, though. but it includes a python server, which can do it for you, using python-dateutil: http://labix.org/python-dateutil

I needed this functionality myself, along with time zone support, so I made a typescript/javascript library: rSchedule .

Currently supports all ICAL recurrence rules except BYSETPOS, BYWEEKNO, and BYYEARDAY. Supports serialization to/from ICAL format along with a ton of extra stuff.

Example:

const rule = new RRule({
  frequency: 'YEARLY',
  byMonthOfYear: [2, 6],
  byDayOfWeek: ['SU', ['MO', 3]],
  start: new Date(2010,1,7),
}, {
  dateAdapter: StandardDateAdapter
})

let index = 0;
for (const date of rule.occurrences()) {
  date.toISOString()
  index++

  if (index > 10) break;
}

rule.occurrences({
  start: new Date(2010,5,7),
  take: 5
})
  .toArray()
  .map(date => date.toISOString())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM