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

Adding an EXDATE with type date does not set the element's VALUE as DATE #349

Open
semiprime opened this issue Jan 29, 2022 · 0 comments
Open

Comments

@semiprime
Copy link
Contributor

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:

ev.add('EXDATE', exdate, parameters={'VALUE':'DATE'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants