Skip to content

Match date-valued EXDATEs against DATE-TIME occurrences - #151

Open
RClaudiuM wants to merge 1 commit into
py-vobject:masterfrom
RClaudiuM:fix/68-exdate-date-value
Open

RClaudiuM wants to merge 1 commit into
py-vobject:masterfrom
RClaudiuM:fix/68-exdate-date-value

Conversation

@RClaudiuM

Copy link
Copy Markdown

An EXDATE;VALUE=DATE:... is turned into a naive midnight datetime before it goes into the rruleset. That breaks in two ways when DTSTART is a DATE-TIME:

  • With a time zone aware DTSTART (Z or TZID=), iterating getrruleset() raises TypeError: can't compare offset-naive and offset-aware datetimes. That's the traceback in Fail to return end date for ended recurring VEVENT #68.
  • With a floating DTSTART, the exclusion is compared against e.g. 18:00 occurrences, never matches, and nothing gets excluded.

This change gives a date-valued EXDATE the same time of day and tzinfo as DTSTART (datetime.combine(date, dtstart.timetz())). That's how dateutil builds the occurrences, so the value matches the occurrence on that day. All-day events (date DTSTART) and RDATE handling are unchanged.

Fixes #68

Before (the .ics from the issue, trimmed):

TypeError: can't compare offset-naive and offset-aware datetimes

After: 6 occurrences, without 2016-05-04 and 2016-06-08. I also checked that exclusions on the far side of a DST change still match for TZID=Europe/Oslo and TZID=US/Pacific.

Tests

  • New test_recurrence_exdate_date_value_with_datetime_dtstart (aware and floating DTSTART). It fails on master and passes with the fix.
  • pytest: 78 passed
  • pre-commit run on the changed files (isort, black, flake8, pylint): all pass

An EXDATE with VALUE=DATE was added to the rruleset as a naive midnight
datetime. When DTSTART is a time zone aware DATE-TIME, iterating the
rruleset raised "can't compare offset-naive and offset-aware datetimes";
with a floating DTSTART the exclusion silently matched nothing.

Give such dates DTSTART's time of day and time zone so they exclude the
occurrence on that day.

Fixes py-vobject#68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to return end date for ended recurring VEVENT

1 participant