diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7480b3b..4e35f43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 + rev: v0.11.9 hooks: - id: ruff args: [--config, "pyproject.toml", --fix] diff --git a/recurring_ical_events/adapters/component.py b/recurring_ical_events/adapters/component.py index 20192c1..ef2305f 100644 --- a/recurring_ical_events/adapters/component.py +++ b/recurring_ical_events/adapters/component.py @@ -116,7 +116,9 @@ def as_component( for subcomponent in self._component.subcomponents: copied_component.add_component(subcomponent) if "RECURRENCE-ID" not in copied_component: - copied_component["RECURRENCE-ID"] = copied_component["DTSTART"] + copied_component["RECURRENCE-ID"] = vDDDTypes( + copied_component["DTSTART"].dt + ) return copied_component @cached_property diff --git a/recurring_ical_events/test/calendars/issue_243_recurrence_id_is_not_identical_to_dtstart.ics b/recurring_ical_events/test/calendars/issue_243_recurrence_id_is_not_identical_to_dtstart.ics new file mode 100644 index 0000000..af4816d --- /dev/null +++ b/recurring_ical_events/test/calendars/issue_243_recurrence_id_is_not_identical_to_dtstart.ics @@ -0,0 +1,10 @@ +BEGIN:VCALENDAR +BEGIN:VEVENT +SUMMARY:daily testing +DTSTART:20150901T080000 +DTEND:20150901T100000 +DTSTAMP:20250529T181439Z +UID:test1 +RRULE:FREQ=DAILY +END:VEVENT +END:VCALENDAR diff --git a/recurring_ical_events/test/test_issue_243_recurrence_id_is_not_identical_to_dtstart.py b/recurring_ical_events/test/test_issue_243_recurrence_id_is_not_identical_to_dtstart.py new file mode 100644 index 0000000..11c0694 --- /dev/null +++ b/recurring_ical_events/test/test_issue_243_recurrence_id_is_not_identical_to_dtstart.py @@ -0,0 +1,33 @@ +"""The RECURRENCE-ID should not be identical to DTSTART. + +That is confusing. +See https://github.com/niccokunzmann/python-recurring-ical-events/issues/243 +""" + +from datetime import datetime + + +def test_recurrence_id_is_not_identical_to_dtstart(calendars): + """We need to make sure they are distinct to set the values independently.""" + start = datetime(2015,9,1) + end = datetime(2015,9,4) + recurrings = calendars.issue_243_recurrence_id_is_not_identical_to_dtstart.between(start, end) + r = recurrings[0] + + ## This break, it should pass + assert id(r["dtstart"]) != id(r["recurrence-id"]) + assert r["dtstart"] is not r["recurrence-id"] + + ## This is true + assert r["recurrence-id"].dt == datetime(2015,9,1,8) + + ## The test recurrence at this particlar day should start at 9, not at 8 + r["dtstart"].dt = datetime(2015,9,1,9) + + ## This should not break, but breaks + assert r["recurrence-id"].dt == datetime(2015,9,1,8) + + r["dtstart"] = datetime(2015,9,1,9) + + ## This should not break, but breaks + assert r["recurrence-id"].dt == datetime(2015,9,1,8)