A bug when getting calendar event data via caldav library

Hello together,

I am getting my calendar events by a caldav library written in Python. It all looks good when I manually input events that are for a whole day. On the other hand when I input an event with a certain time span into my calendar and get those via my python script it has the wrong DTSTART attribute.

I will give an example: I input an event on the 08/07/2020 with the time 10:00 until 11:00. When I call my script and get this event every attribute is correct except for the datetime attributes which curiously always show 25/10/1970 as the date (dtstart, dtend, created, last modified). The time variable is also wrong, being 02 am until 03 am most of the time.

Does anyone have an idea why this happens?

Thank you very much.

Check the source code of the event by exporting it to a vcf file. You will see that the structure of an event looks like this:

BEGIN:VCALENDAR
  PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
  VERSION:2.0
  BEGIN:VTIMEZONE
    TZID:Europe/Berlin
    BEGIN:DAYLIGHT
      TZOFFSETFROM:+0100
      TZOFFSETTO:+0200
      TZNAME:CEST
      DTSTART:19700329T020000
      RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
    END:DAYLIGHT
    BEGIN:STANDARD
      TZOFFSETFROM:+0200
      TZOFFSETTO:+0100
      TZNAME:CET
      DTSTART:19701025T030000
      RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
    END:STANDARD
  END:VTIMEZONE
  BEGIN:VEVENT
    CREATED:20200628T150832Z
    LAST-MODIFIED:20200701T113014Z
    DTSTAMP:20200701T113014Z
    UID:fe7c237f-e645-4f8a-919d-bd18e9ffc5b2
    SUMMARY: Test-Summary
    DTSTART;TZID=Europe/Berlin:20200701T120000
    DTEND;TZID=Europe/Berlin:20200701T123000
    BEGIN:VALARM
      ACTION:DISPLAY
      TRIGGER;VALUE=DURATION:-PT30M
      DESCRIPTION:Test-Event
    END:VALARM
  END:VEVENT
END:VCALENDAR

As you can see the file contains multiple DTSTART attributes and you most likely grepping the wrong one. Only the one within the VEVENT block will give you the correct start and end time of the event :wink:

DTSTART;TZID=Europe/Berlin:20200701T120000
DTEND;TZID=Europe/Berlin:20200701T123000
1 Like

Curiously I didn’t see the first DTSTART when I printed out the event data. But after getting the substring between BEGIN:VEVENT and END:VEVENT everything worked out perfectly. Thank you very much! :hugs:

1 Like

Would you mind sharing some example code?