You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you set an EXDATE with an argument of type datetime.date, iCalendar does not set the VALUE of the element as DATE.
This violates RFC5545 section 3.8.5.1, which states that:
Value Type: The default value type for this property is DATE-TIME.
The value type can be set to DATE.
and (in the format definition)
;Value MUST match value type
Minimal code to reproduce:
import icalendar
import datetime
# Create an event with necessary elements
ev = icalendar.Event()
ev.add('UID', 'ical-test-20220129')
ev.add('DTSTAMP', datetime.datetime.now(datetime.timezone.utc))
ev.add('SUMMARY', 'EXDATE test')
# Add a date as start date
date = datetime.date(year=2022, month=1, day=1)
ev.add('DTSTART', date)
# Add weekly repeat rule
ev.add('RRULE', {'FREQ':'WEEKLY'})
# Add a date as exception date
exdate = datetime.date(year=2022, month=1, day=8)
ev.add('EXDATE', exdate)
print(ev.to_ical().decode())
With Python 3.9.10, icalendar 4.0.9, this gives output:
BEGIN:VEVENT
SUMMARY:EXDATE test
DTSTART;VALUE=DATE:20220101
DTSTAMP;VALUE=DATE-TIME:20220129T154609Z
UID:ical-test-20220129
RRULE:FREQ=WEEKLY
EXDATE:20220108
END:VEVENT
The error is that the EXDATE line should read:
EXDATE;VALUE=DATE:20220108
Note that in the above code, setting the DTSTART and DTSTAMP elements correctly sets their VALUE parameter from the given argument.
Workaround: The add('EXDATE',...) call can be changed to explicitly set the VALUE:
If you set an EXDATE with an argument of type datetime.date, iCalendar does not set the VALUE of the element as DATE.
This violates RFC5545 section 3.8.5.1, which states that:
and (in the format definition)
Minimal code to reproduce:
With Python 3.9.10, icalendar 4.0.9, this gives output:
The error is that the EXDATE line should read:
Note that in the above code, setting the DTSTART and DTSTAMP elements correctly sets their VALUE parameter from the given argument.
Workaround: The add('EXDATE',...) call can be changed to explicitly set the VALUE:
The text was updated successfully, but these errors were encountered: