rrule处理日历复发规则
rrule 是一个处理日历日期复发规则的 JavaScript 库。
rrule.js 支持在 iCalendar RFC 定义的复发规则,这是从优秀的 python-dateutil 库的 RRULE 模块的部分端口。最重要的是,它支持解析和序列化自然语言的复发规则。
使用示例:
// Create a rule: var rule = new RRule({ freq: RRule.WEEKLY, interval: 5, byweekday: [RRule.MO, RRule.FR], dtstart: new Date(2012, 1, 1, 10, 30), until: new Date(2012, 12, 31) }); // Get all occurrence dates (Date instances): rule.all(); ['Fri Feb 03 2012 10:30:00 GMT+0100 (CET)', 'Mon Mar 05 2012 10:30:00 GMT+0100 (CET)', 'Fri Mar 09 2012 10:30:00 GMT+0100 (CET)', 'Mon Apr 09 2012 10:30:00 GMT+0200 (CEST)', /* … */] // Get a slice: rule.between(new Date(2012, 7, 1), new Date(2012, 8, 1)) ['Mon Aug 27 2012 10:30:00 GMT+0200 (CEST)', 'Fri Aug 31 2012 10:30:00 GMT+0200 (CEST)'] // Get an iCalendar RRULE string representation: // The output can be used with RRule.fromString(). rule.toString(); "FREQ=WEEKLY;DTSTART=20120201T093000Z;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR" // Get a human-friendly text representation: // The output can be used with RRule.fromText(). rule.toText() "every 5 weeks on Monday, Friday until January 31, 2013"
评论