Skip to content

Commit 904f0ff

Browse files
committed
Show only future events
1 parent b06deb3 commit 904f0ff

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/App.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ical from 'ical/ical.js';
22
import useFetch from './swr.js';
33
import { Fragment, useMemo, useState } from 'react';
4-
import { compareAsc, format, isThisMonth } from 'date-fns';
4+
import { compareAsc, format, isThisMonth, isFuture } from 'date-fns';
55
import { bg } from 'date-fns/locale';
66

77
function App() {
@@ -23,7 +23,9 @@ function App() {
2323
}
2424

2525
const parsed = ical.parseICS(data);
26-
const events = Object.values(parsed).filter(item => item.type === 'VEVENT').sort((a, b) =>
26+
const events = Object.values(parsed).filter(item =>
27+
item.type === 'VEVENT' && isFuture(item.start)
28+
).sort((a, b) =>
2729
compareAsc(a.start, b.start)
2830
);
2931

0 commit comments

Comments
 (0)