是否有任何可以处理重复(RRULE)事件的节点读取器?

时间:2018-10-09 13:33:42

标签: node.js npm google-calendar-api icalendar rrule

使用this demo calendar

对于日历阅读器,输出如下所示:

screenclip 215

但是从npm上的各个节点工程以及它们的各个fork中,我得到的只是:

On 2018-10-09, Event repeating monthly on 2nd tuesday at 10am
On 2018-10-10, Event repeating weekly on a Wednesday at 11am
On 2018-10-11, Single event on 11th October

代码如下-一些额外的功能,因为我只对将来的日期感兴趣,所以很高兴能按即将到来的日期顺序进行操作,而不是按随机顺序进行

const ical = require('ical');
var dateNow = new Date();

const url = "https://calendar.google.com/calendar/ical/ssjqjrg27h9mqqctfnr5kscmrk%40group.calendar.google.com/public/basic.ics";

  ical.fromURL(url, {}, function (err, data) {
    var ttsorted = [];
    for (const k in data) {
      const ev = data[k];
      const eventStart = new Date(ev.start);
      if (data.hasOwnProperty(k)) {
      if (eventStart.getTime() >= dateNow.getTime()) {
          const tts = `On ${ev.start.toISOString().slice(0,10)}, ${ev.summary} `;
          ttsorted.push(tts);
        }
     }
    }
    ttsorted.sort();
    for (const events of ttsorted) {
      console.log(events);
    }
  });

0 个答案:

没有答案