I assume the issue is daylight savings. I just can’t figure out a fix
My setup. I have a schedule view. on which I want to display the users Calendar events on. Each day in the schedule queries for any events using
func fetchSystemCalendarEventForDate(_ date: Date) -> [EKEvent]{
let calendars = CalendarManager.sharedInstance.eventStore.calendars(for: .event)
let predicate = CalendarManager.sharedInstance.eventStore.predicateForEvents(withStart: date, end: date.endOfDay, calendars: calendars)
return CalendarManager.sharedInstance.eventStore.events(matching: predicate).filter({$0.calendar.title != "myAppCal" })
}
The date passed in has time of 00:00:00
the .endOfDay
modifier sets the time to 23:59:00
If for example the 26th July 2024 was queried and it returns an EKEvent
the user has set to be allDay. It is also returned when the 25th July 2024 queries the fetchSystemCalendarEventForDate(_ date: Date)
function.
If I try moving the date for the withStart
argument ahead 2 hours with .addingTimeInterval(7200)
. It Still shows on both the 26th and 25th.
The When printing out the event.startDate
& event.endDate
I get
00:00 23:59 25 July 2024
as expected. Only this is also what is printed out for 26th July even though the event ended 23:59 the day before.