niccokunzmann/python-recurring-ical-events

bug: event timezones not standardized

Closed this issue · 7 comments

Describe the bug
When an event has a specific TZID, either because the event was added from a different calendar or by user's decision to manually change the timezone, recurring-ical-events fails to convert the date times to adjust for the unusual timezone, leaving the processed time to be inaccurate.

To Reproduce
make a calendar event with a timezone different than the one in the calendar header. Resulting raw event DT might look like this:
DTSTART;TZID=America/New_York:20211102T110000
then load the calendar and print out event['DTSTART']

Hi @asimonson1125, thanks for reporting this... To be sure that we talk about the same thing ... could you post a whole ics file which can show the issue? The next steps are the tests, then...

Hi @asimonson1125, thanks for reporting this... To be sure that we talk about the same thing ... could you post a whole ics file which can show the issue? The next steps are the tests, then...

Sure, here's an example. It's in a txt file because that is what github will let me upload, but the contents are the same:
broken.txt
It isn't formatted exactly the same as the originally reported example, but the error remains the same. I believe Google updated their calendar exports since my intial report to standardize timezones about GMT so I'm struggling to determine where exactly the date is being displayed incorrectly.

This was my test:

import urllib.request
import recurring_ical_events
import datetime
import icalendar
import arrow


# Gets calendar from ICS file ------------------------------------------------------
#f = open("broken.ics", 'r')
#calendario = icalendar.Calendar.from_ical(f.read())
#f.close()
myUrl = "https://calendar.google.com/calendar/ical/c_grbi06ec0hl1s9gi46c3ooqvsc%40group.calendar.google.com/public/basic.ics"
ical_string = urllib.request.urlopen(myUrl).read()
calendario = icalendar.Calendar.from_ical(ical_string)


# --------------------------------------------------------------------------------------------


events = recurring_ical_events.of(calendario).between(datetime.datetime(2021, 12, 22), datetime.datetime(2021, 12, 23) + datetime.timedelta(days=2)) 

for i in range(len(events)): # For each event in the next 2 days...
    eName = events[i]['SUMMARY'] # Event name in string
    eStart = events[i]['DTSTART'].dt # Event start time in dt
    eEnd = events[i]['DTEND'].dt # Event end time in dt
    print(eName, "\n\tStarts: ", eStart, "\n\tDuration: ", eEnd - eStart, '\n')

and output:

Google says this is 9PM to 10PM on 12/22/2021 
	Starts:  2021-12-23 02:00:00+00:00 
	Duration:  1:00:00 

Google recognizes this as EST 5PM-6PM 
	Starts:  2021-12-22 22:00:00+00:00 
	Duration:  1:00:00 

Google Calendar says this is noon to 1PM on 12/22/2021 
	Starts:  2021-12-22 17:00:00+00:00 
	Duration:  1:00:00 

To me, this looks like X-WR-TIMEZONE is involved, #53. You are person 3 to report a different expected behaviour. It could well be that there should be a uniform way of handling X-WR-TIMEZONE.

I opened #71 to discuss it because you are not the only one facing this.

What do you think?

I do not have enough experience with ics's to make a hypothesis. I suspect there are multiple problems that were fixed or changed over the course of error reporting (see: my change from the initial report due to google's change in handling), so all I can say is that any tests need to my carefully version controlled.

@asimonson1125 Would you like to give it a try with the latest version? I believe, since X-WR-TIMEZONE support is integrated now, the times should be reported at the mentioned times.