@@ -289,14 +289,21 @@ public async Task<string> CreateEvent(string calendarId, string title, string de
289289 using var cursor = await GetPlatformCalendar ( calendarId ) ;
290290
291291 ContentValues eventToInsert = new ( ) ;
292+ if ( isAllDay )
293+ {
294+ // Set the time component to midnight in UTC for all-day events
295+ startDateTime = new DateTimeOffset ( startDateTime . Date , TimeSpan . Zero ) . ToUniversalTime ( ) ;
296+ endDateTime = new DateTimeOffset ( endDateTime . Date , TimeSpan . Zero ) . ToUniversalTime ( ) ;
297+ }
298+
292299 eventToInsert . Put ( CalendarContract . Events . InterfaceConsts . Dtstart ,
293300 startDateTime . ToUnixTimeMilliseconds ( ) ) ;
294301
295302 eventToInsert . Put ( CalendarContract . Events . InterfaceConsts . Dtend ,
296303 endDateTime . ToUnixTimeMilliseconds ( ) ) ;
297304
298305 eventToInsert . Put ( CalendarContract . Events . InterfaceConsts . EventTimezone ,
299- TimeZoneInfo . Local . Id ) ;
306+ isAllDay ? "UTC" : TimeZoneInfo . Local . Id ) ;
300307
301308 eventToInsert . Put ( CalendarContract . Events . InterfaceConsts . AllDay ,
302309 isAllDay ) ;
@@ -519,7 +526,7 @@ DateTimeOffset GetEventStartTime(long eventId)
519526 {
520527 var startTimeMillis = cursor . GetLong ( cursor . GetColumnIndexOrThrow (
521528 CalendarContract . Events . InterfaceConsts . Dtstart ) ) ;
522-
529+
523530 return DateTimeOffset . FromUnixTimeMilliseconds ( startTimeMillis )
524531 . ToLocalTime ( ) ; // Convert to local time
525532
@@ -654,7 +661,7 @@ async Task<ICursor> GetPlatformCalendar(string calendarId)
654661 }
655662
656663 cursor . MoveToNext ( ) ;
657-
664+
658665 return cursor ;
659666 }
660667 catch
@@ -758,7 +765,7 @@ DateTimeOffset SafeConvertTime(DateTimeOffset time, string tz)
758765 Reminders = GetAllEventReminders ( eventId ) ,
759766 } ;
760767 }
761-
768+
762769 static IEnumerable < CalendarEventAttendee > ToAttendees ( ICursor cur , List < string > projection )
763770 {
764771 while ( cur . MoveToNext ( ) )
0 commit comments