Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions src/icalendar/prop/recur/weekday.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def from_ical(cls, ical):
except Exception as e:
raise ValueError(f"Expected weekday abbreviation, got: {ical}") from e

@property
def ical_value(self) -> str:
"""The weekday value (e.g. ``MO``, ``+2TH``, ``-1SU``).
Comment thread
stevepiercy marked this conversation as resolved.
Outdated

See :rfc:`5545#section-3.3.10` for the ``BYDAY`` rule grammar.
Comment thread
stevepiercy marked this conversation as resolved.
Outdated
"""
return str(self)

@classmethod
def parse_jcal_value(cls, value: Any) -> Self:
"""Parse a jCal value for vWeekday.
Expand Down
8 changes: 8 additions & 0 deletions src/icalendar/tests/prop/test_vWeekday.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ def test_error():
"""Error: Expected weekday abbrevation, got: -100MO"""
with pytest.raises(ValueError):
vWeekday.from_ical("-100MO")


def test_ical_value():
"""ical_value property returns the weekday string value."""
assert vWeekday("MO").ical_value == "MO"
assert vWeekday("+2TH").ical_value == "+2TH"
assert vWeekday("-1SU").ical_value == "-1SU"
assert isinstance(vWeekday("MO").ical_value, str)