If today is Tuesday 2PM May 6th
event.startDate = [[NSDate alloc] init];
event.allDay = YES;
[dateFormat setDateFormat:EEEE, MMMM dd, yyyy];
NSString* dayStr = [dateFormat stringFromDate:event.startDate];
timeDetails.text = [NSString stringWithFormat:@"%@\nAll day", dayStr];
results in Monday May 5th
same code without allDay set
event.startDate = [[NSDate alloc] init];
[dateFormat setDateFormat:EEEE, MMMM dd, yyyy];
NSString* dayStr = [dateFormat stringFromDate:event.startDate];
timeDetails.text = [NSString stringWithFormat:@"%@\nAll day", dayStr];
results in Tuesday May 6th which is correct. Anyone has any clues?
Background
In iOS all dates have a time component. So for an all day event, some time is still used. Typically this is midnight to "just before" midnight (23:59), giving the event a span of almost 24 hours.
The challenge comes with timezones and daylight saving. This can mean thats all day events start at 11pm the previous day and finish at 22:59. It all depends on where you are viewing the event from. Unfortunately in iOS development this often isn't clear! I've had some really "fun" bug that only materialise when running the app between 11pm and midnight before.
Fix
Amazingly the behaviour of EKEvent changes according the order that you set the properties. If you set event.allDay = YES before you set the startDate then you will get the behaviour you are expecting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With