Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: dates without time #61

Closed
sirdan69 opened this issue Dec 16, 2021 · 8 comments
Closed

bug: dates without time #61

sirdan69 opened this issue Dec 16, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@sirdan69
Copy link

sirdan69 commented Dec 16, 2021

Describe the bug
First, thanks for this library. It is very helpful.

Our group uses Confluence calendars which allows the scheduling of an All Day event. When these are read by the library, they become datetime.date instead of datetime.datetime and they have no timezone. As a result, the assert on line 52 (assert tzinfo is not None..) is hit. The reason tzinfo is never set is because there are no datetime's found in the calendar.

To Reproduce
import datetime
from pytz import timezone
import recurring_ical_events

calendar = Calendar.from_ical(ics_file) # ics_file is the attached ics file
tz = str(calendar.get('X-WR-TIMEZONE'))
now = datetime.datetime.now(timezone(tz)
recurring_ical_events.of(calendar).at(now)

ICS file

BEGIN:VCALENDAR
PRODID:-//Atlassian Confluence//Calendar Plugin 1.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:danl-test
X-WR-CALDESC:
X-WR-TIMEZONE:America/Los_Angeles
X-MIGRATED-FOR-USER-KEY:true
METHOD:PUBLISH
X-CONFLUENCE-CUSTOM-EVENT-TYPE:false
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
TZURL:http://tzurl.org/zoneinfo/America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
UID:[email protected]
SEQUENCE:0
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:-075258
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:18831118T120702
RDATE:18831118T120702
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:19180331T020000
RDATE:19180331T020000
RDATE:19190330T020000
RDATE:19480314T020100
RDATE:19500430T010000
RDATE:19510429T010000
RDATE:19520427T010000
RDATE:19530426T010000
RDATE:19540425T010000
RDATE:19550424T010000
RDATE:19560429T010000
RDATE:19570428T010000
RDATE:19580427T010000
RDATE:19590426T010000
RDATE:19600424T010000
RDATE:19610430T010000
RDATE:19620429T010000
RDATE:19630428T010000
RDATE:19640426T010000
RDATE:19650425T010000
RDATE:19660424T010000
RDATE:19670430T020000
RDATE:19680428T020000
RDATE:19690427T020000
RDATE:19700426T020000
RDATE:19710425T020000
RDATE:19720430T020000
RDATE:19730429T020000
RDATE:19740106T020000
RDATE:19750223T020000
RDATE:19760425T020000
RDATE:19770424T020000
RDATE:19780430T020000
RDATE:19790429T020000
RDATE:19800427T020000
RDATE:19810426T020000
RDATE:19820425T020000
RDATE:19830424T020000
RDATE:19840429T020000
RDATE:19850428T020000
RDATE:19860427T020000
RDATE:19870405T020000
RDATE:19880403T020000
RDATE:19890402T020000
RDATE:19900401T020000
RDATE:19910407T020000
RDATE:19920405T020000
RDATE:19930404T020000
RDATE:19940403T020000
RDATE:19950402T020000
RDATE:19960407T020000
RDATE:19970406T020000
RDATE:19980405T020000
RDATE:19990404T020000
RDATE:20000402T020000
RDATE:20010401T020000
RDATE:20020407T020000
RDATE:20030406T020000
RDATE:20040404T020000
RDATE:20050403T020000
RDATE:20060402T020000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:19181027T020000
RDATE:19181027T020000
RDATE:19191026T020000
RDATE:19450930T020000
RDATE:19490101T020000
RDATE:19500924T020000
RDATE:19510930T020000
RDATE:19520928T020000
RDATE:19530927T020000
RDATE:19540926T020000
RDATE:19550925T020000
RDATE:19560930T020000
RDATE:19570929T020000
RDATE:19580928T020000
RDATE:19590927T020000
RDATE:19600925T020000
RDATE:19610924T020000
RDATE:19621028T020000
RDATE:19631027T020000
RDATE:19641025T020000
RDATE:19651031T020000
RDATE:19661030T020000
RDATE:19671029T020000
RDATE:19681027T020000
RDATE:19691026T020000
RDATE:19701025T020000
RDATE:19711031T020000
RDATE:19721029T020000
RDATE:19731028T020000
RDATE:19741027T020000
RDATE:19751026T020000
RDATE:19761031T020000
RDATE:19771030T020000
RDATE:19781029T020000
RDATE:19791028T020000
RDATE:19801026T020000
RDATE:19811025T020000
RDATE:19821031T020000
RDATE:19831030T020000
RDATE:19841028T020000
RDATE:19851027T020000
RDATE:19861026T020000
RDATE:19871025T020000
RDATE:19881030T020000
RDATE:19891029T020000
RDATE:19901028T020000
RDATE:19911027T020000
RDATE:19921025T020000
RDATE:19931031T020000
RDATE:19941030T020000
RDATE:19951029T020000
RDATE:19961027T020000
RDATE:19971026T020000
RDATE:19981025T020000
RDATE:19991031T020000
RDATE:20001029T020000
RDATE:20011028T020000
RDATE:20021027T020000
RDATE:20031026T020000
RDATE:20041031T020000
RDATE:20051030T020000
RDATE:20061029T020000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PWT
DTSTART:19420209T020000
RDATE:19420209T020000
END:DAYLIGHT
BEGIN:DAYLIGHT
TZOFFSETFROM:-0700
TZOFFSETTO:-0700
TZNAME:PPT
DTSTART:19450814T160000
RDATE:19450814T160000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0800
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:19460101T000000
RDATE:19460101T000000
RDATE:19670101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20211216T020448Z
DTSTART;VALUE=DATE:20211215
DTEND;VALUE=DATE:20211216
SUMMARY:test
CATEGORIES:other
SUBCALENDAR-ID:1cfd6797-ae26-4858-b13a-eac08fa24d7d
PARENT-CALENDAR-ID:13e26edc-772b-44ba-9dfb-02a11f7f9825
PARENT-CALENDAR-NAME:
SUBSCRIPTION-ID:
SUBCALENDAR-TZ-ID:America/Los_Angeles
SUBCALENDAR-NAME:danl-test
EVENT-ID:89058
EVENT-ALLDAY:true
UID:[email protected]
DESCRIPTION:test event
ORGANIZER;X-CONFLUENCE-USER-KEY=8a4a8a8e5418da4e015496587b6d0067;CN=Danie
l Latham;CUTYPE=INDIVIDUAL:mailto:[email protected]
CREATED:20211215T183642Z
LAST-MODIFIED:20211215T213515Z
ATTENDEE;X-CONFLUENCE-USER-KEY=8a4a8a8e5418da4e015496587b6d0067;CN=Daniel
 Latham;CUTYPE=INDIVIDUAL:mailto:[email protected]
SEQUENCE:5
X-CONFLUENCE-SUBCALENDAR-TYPE:other
TRANSP:TRANSPARENT
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR

Expected behavior
if the default tzinfo from the calendar, the code works as-is.

Console output
none

Version:

latest

Additional context
none

Suggested implementation
My thought for a fix would be to initialize tzinfo with the timezone from the calendar. It exists in the Confluence calendar file, but I don't know if that's a standard field.

@sirdan69 sirdan69 added the bug Something isn't working label Dec 16, 2021
@niccokunzmann
Copy link
Owner

Wow, thanks for reporting this! It is true, that the calendar time zone is not used for the events.... I wonder though, where to put the responsibility as the parser icalendar might really not be the right place for inheriting time zones from the calendar to the event. Maybe in the mean time, it would be good to have references from the standard.

@niccokunzmann
Copy link
Owner

I had a look at the ICS file. There is no reason that I can see why there should be a time zone in the ICS event.

Looking at your code, I think that maybe, you would like to use a datetime.date as now in at(now). We shall see..

@niccokunzmann
Copy link
Owner

By the way: There is a mistake:

Here, a ':' is expected, not a ';'

ORGANIZER;X-CONFLUENCE-USER-KEY=8a4a8a8e5418da4e015496587b6d0067;CN=Danie
ATTENDEE;X-CONFLUENCE-USER-KEY=8a4a8a8e5418da4e015496587b6d0067;CN=Daniel
 Latham;CUTYPE=INDIVIDUAL:mailto:[email protected]

@niccokunzmann
Copy link
Owner

Okay, it seems that the SUBCALENDAR-TZ-ID does not exist in the standard, see https://duckduckgo.com/?q=icalendar+%22SUBCALENDAR-TZ-ID%22&t=ffab&ia=web

So, what you can do to have events with a time zone, is that you go though the calendar yourself and modify the events based on the SUBCALENDAR-TZ-ID attribute. After you have done this, you can pass them to recurring_ical_events.
I am not sure that I would like to put the complexity of people's code which do not go by the standard into the library. Surely, you can write to them and tell them what you expect and that they are incompatible with what you expect. You can even direct them to this issue if they would like to discuss it.

But it is right: as pointed out in #63, you should still be allowed to pass the argument, I would assume.

@niccokunzmann
Copy link
Owner

A fix is deployed from version v0.2.3b on.

@niccokunzmann
Copy link
Owner

#53 is of interest to you... The problem being the X-WR-TIMEZONE:America/Los_Angeles. I guess that we should discuss supporting such behavior in #53.

@sirdan69
Copy link
Author

Nicco, thanks for looking into this and fixing the crash. I'll try the updated version and take a look at #53.

@niccokunzmann
Copy link
Owner

I opened #71 to discuss X-WR-TIMEZONE because you are not the only one facing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants