mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
582 stars 86 forks source link

[Question] Handling events in UTC #207

Open infpmandin opened 2 years ago

infpmandin commented 2 years ago

Hello,

I tried creating events with start/end datetime in utc:

BEGIN:VCALENDAR PRODID:Microsoft Exchange Server 2010 VERSION:2.0 BEGIN:VEVENT X-MICROSOFT-DISALLOW-COUNTER:FALSE X-MICROSOFT-DONOTFORWARDMEETING:FALSE X-MICROSOFT-CDO-INSTTYPE:0 X-MICROSOFT-CDO-IMPORTANCE:1 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY X-MICROSOFT-CDO-BUSYSTATUS:BUSY X-MICROSOFT-CDO-OWNERAPPTID:2120381309 X-MICROSOFT-CDO-APPT-SEQUENCE:1 DTEND:20220215T110400Z DTSTART:20220215T100400Z DESCRIPTION:Sdfgsgseg\n2\n SUMMARY;LANGUAGE=en-US:ANALYSE : SDFSFSF CLASS:PUBLIC PRIORITY:5 DTSTAMP:20220214T103942Z TRANSP:OPAQUE STATUS:CONFIRMED SEQUENCE:2 UID:20220214T111002425432 END:VEVENT END:VCALENDAR

When sending the event to the Exchange server through Davmail, I have this in davmail.log:

2022-02-14 11:45:05,772 DEBUG [CaldavConnection-56263] davmail.exchange.ExchangeSession - Fixed Vcalendar body to server: BEGIN:VCALENDAR PRODID:Microsoft Exchange Server 2010 VERSION:2.0 METHOD:PUBLISH BEGIN:VTIMEZONE TZID:Romance Standard Time BEGIN:STANDARD DTSTART:16010101T030000 TZOFFSETFROM:+0200 TZOFFSETTO:+0100 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10 END:STANDARD BEGIN:DAYLIGHT DTSTART:16010101T020000 TZOFFSETFROM:+0100 TZOFFSETTO:+0200 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3 END:DAYLIGHT END:VTIMEZONE BEGIN:VEVENT X-MICROSOFT-DISALLOW-COUNTER:FALSE X-MICROSOFT-DONOTFORWARDMEETING:FALSE X-MICROSOFT-CDO-INSTTYPE:0 X-MICROSOFT-CDO-IMPORTANCE:1 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY X-MICROSOFT-CDO-BUSYSTATUS:BUSY X-MICROSOFT-CDO-OWNERAPPTID:2120381309 X-MICROSOFT-CDO-APPT-SEQUENCE:1 DTEND;TZID=Romance Standard Time:20220215T110400Z DTSTART;TZID=Romance Standard Time:20220215T100400Z DESCRIPTION:Sdfgsgseg\n2\n SUMMARY;LANGUAGE=en-US:ANALYSE : SDFSFSF CLASS:PUBLIC PRIORITY:5 DTSTAMP:20220214T103942Z TRANSP:OPAQUE STATUS:CONFIRMED SEQUENCE:2 UID:20220214T111002425432 ORGANIZER:MAILTO:xxx@mydomain END:VEVENT END:VCALENDAR

So the event I want starting at 10:04 (UTC) is created at 10:04 (Romance Standard time, i.e. GMT+1) in my Exchange calendar, so 1 hour shifted. Did I make something wrong when creating my event?

infpmandin commented 2 years ago

I tried this simple patch in VCalendar.java, according to https://datatracker.ietf.org/doc/html/rfc2445#section-4.3.5 related to DATE-TIME values


Index: VCalendar.java
===================================================================
--- VCalendar.java  (révision 3399)
+++ VCalendar.java  (copie de travail)
@@ -421,7 +421,10 @@

     private void fixTzid(VProperty property) {
         if (property != null && !property.hasParam("TZID")) {
-            property.addParam("TZID", vTimezone.getPropertyValue("TZID"));
+            // No TZID for UTC timezone
+            if (!property.getValue().endsWith("Z")) {
+                property.addParam("TZID", vTimezone.getPropertyValue("TZID"));
+            }
         }
     }

It is not enough, as the Exchange server now throws an error: ErrorInvalidPropertyDelete The delete action is not supported for this property. FieldURI: calendar:StartTimeZone so I suppose it tries to delete empty properties.

[20220228] It seems the start and end timezone are mandatory in Exchange EWS API, so I suppose I need to set a "Etc/Utc" timezone in the event sent to the Exchange server.