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

Fix recurrence rule UNTIL string serialization #122

Merged
merged 2 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ical/types/recur.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def __encode_property_value__(cls, data: dict[str, Any]) -> str:
occurrence = ""
values.append(f"{occurrence}{weekday}")
value = ",".join(values)
elif isinstance(value, datetime.datetime):
value = DateTimeEncoder.__encode_property_json__(value)
if not value:
continue
result.append(f"{key.upper()}={value}")
Expand Down
15 changes: 15 additions & 0 deletions tests/types/test_recur.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,18 @@ def test_recur_as_string() -> None:
)
assert event.rrule
assert event.rrule.as_rrule_str() == "FREQ=DAILY;INTERVAL=2"


def test_recur_until_as_string() -> None:
"""Test converting a recurrence rule with a date into a string."""

event = Event(
summary="summary",
start=datetime.datetime(2022, 8, 1, 6, 0, 0),
end=datetime.datetime(2022, 8, 2, 6, 30, 0),
rrule=Recur(
freq=Frequency.DAILY, until=datetime.datetime(2022, 8, 10, 6, 0, 0)
),
)
assert event.rrule
assert event.rrule.as_rrule_str() == "FREQ=DAILY;UNTIL=20220810T060000;INTERVAL=1"