Skip to content

Commit c5507a9

Browse files
committed
[F] Fix Calendar.vue recurring events display (#30)
1 parent 376b0f6 commit c5507a9

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

content/Calendar.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,28 @@ const fetchIcal = async () => {
2929
3030
const _tmp = [];
3131
for (let k in cal) _tmp.push(cal[k]);
32-
const events = _tmp.filter((ev) => ev.type == 'VEVENT' && ev.start && ev.start > now);
32+
33+
const events: CalendarComponent[] = [];
34+
_tmp.forEach((ev) => {
35+
if (ev.type !== 'VEVENT' || !ev.start) return;
36+
37+
if (ev.rrule) {
38+
// Expand the recurring events for the next 90 days
39+
const limit = new Date(now.getTime() + 90 * 24 * 60 * 60 * 1000);
40+
const dates = ev.rrule.between(now, limit, true);
41+
dates.forEach((date) => {
42+
const clone = { ...ev };
43+
clone.start = date;
44+
if (ev.end) {
45+
const duration = ev.end.getTime() - ev.start.getTime();
46+
clone.end = new Date(date.getTime() + duration);
47+
}
48+
events.push(clone);
49+
});
50+
} else if (ev.start > now) {
51+
events.push(ev);
52+
}
53+
});
3354
3455
// If there are no upcoming events, show one from the past
3556
if (events.length == 0) {

0 commit comments

Comments
 (0)