use actual occurrences in date list

This commit is contained in:
2024-06-05 23:00:07 +02:00
parent 4842dcc7f5
commit c974e296ef
5 changed files with 98 additions and 12 deletions

View File

@ -63,6 +63,8 @@ const EventFragmentDefinition = graphql(`
id
slug
title
preposition
url
}
}
}
@ -102,9 +104,13 @@ export function getSingularEvents(events: EventFragment[]): SingularEvent[] {
.flat();
}
export function compareDates(a: Date | string, b: Date | string) {
return compareAsc(new Date(a), new Date(b));
}
export function sortSingularEvents(events: SingularEvent[]) {
return events.sort((a, b) =>
compareAsc(new Date(a.occurrence.start), new Date(b.occurrence.start))
compareDates(a.occurrence.start, b.occurrence.start)
);
}
interface EventsByDate {