icalendar.prop.recur.weekday module#

BYWEEKDAY, BYDAY, and WKST value type of RECUR from RFC 5545.

class icalendar.prop.recur.weekday.vWeekday(value, encoding='utf-8', /, params: dict[str, Any] | None = None)[source]#

Bases: str

Either a weekday or a weekdaynum.

>>> from icalendar import vWeekday
>>> vWeekday("MO") # Simple weekday
'MO'
>>> vWeekday("2FR").relative # Second friday
2
>>> vWeekday("2FR").weekday
'FR'
>>> vWeekday("-1SU").relative # Last Sunday
-1

Definition from RFC 5545 Section 3.3.10:

weekdaynum = [[plus / minus] ordwk] weekday
plus        = "+"
minus       = "-"
ordwk       = 1*2DIGIT       ;1 to 53
weekday     = "SU" / "MO" / "TU" / "WE" / "TH" / "FR" / "SA"
;Corresponding to SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY,
;FRIDAY, and SATURDAY days of the week.
classmethod from_ical(ical)[source]#
property ical_value: str#

Return the Python string value.

This property provides access to the underlying weekday string value, which may be a simple weekday (e.g., "MO") or a weekday with relative position (e.g., "2FR" for second Friday, "-1SU" for last Sunday).

Returns:

The weekday string value.

Return type:

str

Example

>>> from icalendar.prop import vWeekday
>>> wd = vWeekday("MO")
>>> wd.ical_value
'MO'
>>> wd2 = vWeekday("2FR")
>>> wd2.ical_value
'2FR'
>>> wd3 = vWeekday("-1SU")
>>> wd3.ical_value
'-1SU'

See also

RFC 5545 Section 3.3.10 for the weekday value type specification.

params: Parameters#
classmethod parse_jcal_value(value)[source]#

Parse a jCal value for vWeekday.

Raises:

JCalParsingError – If the value is not a valid weekday.

Return type:

None

relative#
to_ical()[source]#
week_days = {'FR': 5, 'MO': 1, 'SA': 6, 'SU': 0, 'TH': 4, 'TU': 2, 'WE': 3}#
weekday#