简体   繁体   English

日历上的重复事件:RFC 5545 Javascript解析

[英]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. 我需要将重复发生的事件集成到全日历的改编版本中,该版本具有添加的javascript模块,允许离线事件浏览。

I'm looking for a javascript library that can parse recurring events according to RFC 5545. 我正在寻找一个可以根据RFC 5545解析重复事件的JavaScript库。

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. 我需要能够列出2个日期(开始日期和结束日期)之间发生的所有重复事件,使用RRULE和EXDATE并解释每日,每周,每月和每年的重复。

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? 我花了几个小时寻找无用的东西,我不想重新发明轮子......任何人都可以指出我正确的方向为现有的JavaScript解析器吗?

I checked into skyporters rrule_parser and found that it doesn't support all of the rules (particularly, it won't do BYDAY properly). 我检查了skyporters rrule_parser并发现它不支持所有规则(特别是,它不会正确地做BYDAY)。 I found a fantastic alternative: 我找到了一个很棒的选择:

https://github.com/jakubroztocil/rrule 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). 您可以使用5545格式或纯文本进行解析(使用nlp扩展名)。 It is feature packed and, as far as I can tell, fully functioning. 这是功能丰富,据我所知,功能齐全。

look into https://github.com/skyporter/rrule_parser . 看看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. 这是jquery的重复小部件,它解析/创建RFC5545兼容的重复字符串。

https://github.com/collective/jquery.recurrenceinput.js 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 但是它包含一个python服务器,可以使用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 . 我自己需要这个功能,还有时区支持,所以我创建了一个打字稿/ javascript库: rSchedule

Currently supports all ICAL recurrence rules except BYSETPOS, BYWEEKNO, and BYYEARDAY. 目前支持除BYSETPOS,BYWEEKNO和BYYEARDAY之外的所有ICAL重复规则。 Supports serialization to/from ICAL format along with a ton of extra stuff. 支持ICAL格式的序列化以及大量额外的东西。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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