diff --git a/api/eventService.ts b/api/eventService.ts index 3f0e0b9..1375f18 100644 --- a/api/eventService.ts +++ b/api/eventService.ts @@ -1,4 +1,5 @@ import { Colors } from '@/styles'; +import dayjs from 'dayjs'; type ApiEventLocation = { term_id: number; @@ -105,15 +106,14 @@ export const determineStartDayIndex = (events: AssemblyEvent[]): number => { } const days = [...new Set(events.map((event) => event.start))]; - const start_day_index = days.findIndex((day) => doorsOpen.start === day); + const startDayIndex = days.findIndex((day) => dayjs(doorsOpen.start).isSame(day, 'day')); - if (start_day_index === -1) { + if (startDayIndex === -1) { console.error("Failed to find matching day for 'Doors Open' event"); return 0; } - // the index returned by findIndex if off by one - return start_day_index - 1; + return startDayIndex; }; const API_BASE_PATH = `https://wp.assembly.org/${determineEvent()}/index.php?rest_route=/api/v1`;