icalendar.cal.availability module#
This implementes the VAVAILABILITY component.
This is specified in RFC 7953.
- class icalendar.cal.availability.Availability(*args, **kwargs)[source]#
Bases:
Component
VAVAILABILITY component from RFC 7953.
This provides a grouping of component properties and subcomponents that describe the availability associated with a calendar user.
- Description:
A “VAVAILABILITY” component indicates a period of time within which availability information is provided. A “VAVAILABILITY” component can specify a start time and an end time or duration. If “DTSTART” is not present, then the start time is unbounded. If “DTEND” or “DURATION” are not present, then the end time is unbounded. Within the specified time period, availability defaults to a free-busy type of “BUSY-UNAVAILABLE” (see Section 3.2), except for any time periods corresponding to “AVAILABLE” subcomponents.
“AVAILABLE” subcomponents are used to indicate periods of free time within the time range of the enclosing “VAVAILABILITY” component. “AVAILABLE” subcomponents MAY include recurrence properties to specify recurring periods of time, which can be overridden using normal iCalendar recurrence behavior (i.e., use of the “RECURRENCE-ID” property).
If specified, the “DTSTART” and “DTEND” properties in “VAVAILABILITY” components and “AVAILABLE” subcomponents MUST be “DATE-TIME” values specified as either the date with UTC time or the date with local time and a time zone reference.
The iCalendar object containing the “VAVAILABILITY” component MUST contain appropriate “VTIMEZONE” components corresponding to each unique “TZID” parameter value used in any DATE-TIME properties in all components, unless [RFC7809] is in effect.
When used to publish available time, the “ORGANIZER” property specifies the calendar user associated with the published available time.
If the “PRIORITY” property is specified in “VAVAILABILITY” components, it is used to determine how that component is combined with other “VAVAILABILITY” components. See Section 4.
Other calendar properties MAY be specified in “VAVAILABILITY” or “AVAILABLE” components and are considered attributes of the marked block of time. Their usage is application specific. For example, the “LOCATION” property might be used to indicate that a person is available in one location for part of the week and a different location for another part of the week (but see Section 9 for when it is appropriate to add additional data like this).
Example
The following is an example of a “VAVAILABILITY” calendar component used to represent the availability of a user, always available Monday through Friday, 9:00 am to 5:00 pm in the America/Montreal time zone:
BEGIN:VAVAILABILITY ORGANIZER:mailto:bernard@example.com UID:0428C7D2-688E-4D2E-AC52-CD112E2469DF DTSTAMP:20111005T133225Z BEGIN:AVAILABLE UID:34EDA59B-6BB1-4E94-A66C-64999089C0AF SUMMARY:Monday to Friday from 9:00 to 17:00 DTSTART;TZID=America/Montreal:20111002T090000 DTEND;TZID=America/Montreal:20111002T170000 RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR END:AVAILABLE END:VAVAILABILITY
You can get the same example from
example()
:The following is an example of a “VAVAILABILITY” calendar component used to represent the availability of a user available Monday through Thursday, 9:00 am to 5:00 pm, at the main office, and Friday, 9:00 am to 12:00 pm, in the branch office in the America/Montreal time zone between October 2nd and December 2nd 2011:
BEGIN:VAVAILABILITY ORGANIZER:mailto:bernard@example.com UID:84D0F948-7FC6-4C1D-BBF3-BA9827B424B5 DTSTAMP:20111005T133225Z DTSTART;TZID=America/Montreal:20111002T000000 DTEND;TZID=America/Montreal:20111202T000000 BEGIN:AVAILABLE UID:7B33093A-7F98-4EED-B381-A5652530F04D SUMMARY:Monday to Thursday from 9:00 to 17:00 DTSTART;TZID=America/Montreal:20111002T090000 DTEND;TZID=America/Montreal:20111002T170000 RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH LOCATION:Main Office END:AVAILABLE BEGIN:AVAILABLE UID:DF39DC9E-D8C3-492F-9101-0434E8FC1896 SUMMARY:Friday from 9:00 to 12:00 DTSTART;TZID=America/Montreal:20111006T090000 DTEND;TZID=America/Montreal:20111006T120000 RRULE:FREQ=WEEKLY LOCATION:Branch Office END:AVAILABLE END:VAVAILABILITY
For more examples, have a look at RFC 5545.
- property DTEND: datetime | None#
The DTEND property. datetime in UTC
All values will be converted to a datetime in UTC. Start of the component.
This is almost the same as
Event.DTEND
with one exception: The values MUST have a timezone and DATE is not allowed.- Description:
RFC 7953: If specified, the “DTSTART” and “DTEND” properties in “VAVAILABILITY” components and “AVAILABLE” subcomponents MUST be “DATE-TIME” values specified as either the date with UTC time or the date with local time and a time zone reference.
- property DTSTART: datetime | None#
The DTSTART property. datetime in UTC
All values will be converted to a datetime in UTC. Start of the component.
This is almost the same as
Event.DTSTART
with one exception: The values MUST have a timezone and DATE is not allowed.- Description:
RFC 7953: If specified, the “DTSTART” and “DTEND” properties in “VAVAILABILITY” components and “AVAILABLE” subcomponents MUST be “DATE-TIME” values specified as either the date with UTC time or the date with local time and a time zone reference.
- property DURATION: timedelta | None#
The DURATION property.
The “DTSTART” property for a “Availability” specifies the inclusive start of the Availability. The “DURATION” property in conjunction with the DTSTART property for a “Availability” calendar component specifies the non-inclusive end of the event.
If you would like to calculate the duration of a Availability, do not use this. Instead use the duration property (lower case).
- property available: list[Available]#
All VAVAILABLE sub-components.
This is a shortcut to get all VAVAILABLE sub-components. Modifications do not change the calendar. Use
Component.add_component()
.
- property busy_type: StrEnum#
BUSYTYPE specifies the default busy time type.
- Returns:
- Description:
This property is used to specify the default busy time type. The values correspond to those used by the FBTYPE” parameter used on a “FREEBUSY” property, with the exception that the “FREE” value is not used in this property. If not specified on a component that allows this property, the default is “BUSY- UNAVAILABLE”.
- canonical_order = ('DTSTART', 'DTEND', 'DURATION', 'DTSTAMP', 'UID', 'SEQUENCE', 'SUMMARY', 'DESCRIPTION', 'ORGANIZER')#
- property categories: list[str]#
This property defines the categories for a component.
- Property Parameters:
IANA, non-standard, and language property parameters can be specified on this property.
- Conformance:
The property can be specified within “VEVENT”, “VTODO”, or “VJOURNAL” calendar components. Since RFC 7986 it can also be defined on a “VCALENDAR” component.
- Description:
This property is used to specify categories or subtypes of the calendar component. The categories are useful in searching for a calendar component of a particular type and category. Within the “VEVENT”, “VTODO”, or “VJOURNAL” calendar components, more than one category can be specified as a COMMA-separated list of categories.
Example
Below, we add the categories to an event:
>>> from icalendar import Event >>> event = Event() >>> event.categories = ["Work", "Meeting"] >>> print(event.to_ical()) BEGIN:VEVENT CATEGORIES:Work,Meeting END:VEVENT >>> event.categories.append("Lecture") >>> event.categories == ["Work", "Meeting", "Lecture"] True
Note
At present, we do not take the LANGUAGE parameter into account.
- property classification: StrEnum#
CLASS specifies the class of the calendar component.
- Returns:
- Description:
An access classification is only one component of the general security system within a calendar application. It provides a method of capturing the scope of the access the calendar owner intends for information within an individual calendar entry. The access classification of an individual iCalendar component is useful when measured along with the other security components of a calendar system (e.g., calendar user authentication, authorization, access rights, access role, etc.). Hence, the semantics of the individual access classifications cannot be completely defined by this memo alone. Additionally, due to the “blind” nature of most exchange processes using this memo, these access classifications cannot serve as an enforcement statement for a system receiving an iCalendar object. Rather, they provide a method for capturing the intention of the calendar owner for the access to the calendar component. If not specified in a component that allows this property, the default value is PUBLIC. Applications MUST treat x-name and iana-token values they don’t recognize the same way as they would the PRIVATE value.
- property contacts: list[str]#
Contact information associated with the calendar component.
- Purpose:
This property is used to represent contact information or alternately a reference to contact information associated with the calendar component.
- Property Parameters:
IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.
- Conformance:
In RFC 5545, this property can be specified in a “VEVENT”, “VTODO”, “VJOURNAL”, or “VFREEBUSY” calendar component. In RFC 7953, this property can be specified in a “VAVAILABILITY” amd “VAVAILABLE” calendar component.
- Description:
The property value consists of textual contact information. An alternative representation for the property value can also be specified that refers to a URI pointing to an alternate form, such as a vCard RFC 2426, for the contact information.
Example
The following is an example of this property referencing textual contact information:
CONTACT:Jim Dolittle\, ABC Industries\, +1-919-555-1234
The following is an example of this property with an alternate representation of an LDAP URI to a directory entry containing the contact information:
CONTACT;ALTREP="ldap://example.com:6666/o=ABC%20Industries\, c=US???(cn=Jim%20Dolittle)":Jim Dolittle\, ABC Industries\, +1-919-555-1234
The following is an example of this property with an alternate representation of a MIME body part containing the contact information, such as a vCard RFC 2426 embedded in a text/ directory media type RFC 2425:
CONTACT;ALTREP="CID:part3.msg970930T083000SILVER@example.com": Jim Dolittle\, ABC Industries\, +1-919-555-1234
The following is an example of this property referencing a network resource, such as a vCard RFC 2426 object containing the contact information:
CONTACT;ALTREP="http://example.com/pdi/jdoe.vcf":Jim Dolittle\, ABC Industries\, +1-919-555-1234
- property description: str | None#
DESCRIPTION provides a more complete description of the calendar component than that provided by the “SUMMARY” property.
- Property Parameters:
IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.
- Conformance:
The property can be specified in the “VEVENT”, “VTODO”, “VJOURNAL”, or “VALARM” calendar components. The property can be specified multiple times only within a “VJOURNAL” calendar component.
- Description:
This property is used in the “VEVENT” and “VTODO” to capture lengthy textual descriptions associated with the activity.
This property is used in the “VALARM” calendar component to capture the display text for a DISPLAY category of alarm, and to capture the body text for an EMAIL category of alarm.
Examples
The following is an example of this property with formatted line breaks in the property value:
DESCRIPTION:Meeting to provide technical review for "Phoenix" design.\nHappy Face Conference Room. Phoenix design team MUST attend this meeting.\nRSVP to team leader.
- property duration: timedelta | None#
Compute the duration of this component.
If there is no
DTEND
orDURATION
set, this is None. Otherwise, the duration is calculated fromDTSTART
andDTEND
/DURATION
.This is in accordance with RFC 7953: If “DTEND” or “DURATION” are not present, then the end time is unbounded.
- property end: timedelta | None#
Compute the duration of this component.
If there is no
DTEND
orDURATION
set, this is None. Otherwise, the duration is calculated fromDTSTART
andDTEND
/DURATION
.This is in accordance with RFC 7953: If “DTEND” or “DURATION” are not present, then the end time is unbounded.
- classmethod example(name: str = 'rfc_7953_1') Availability [source]#
Return the calendar example with the given name.
- exclusive = ('DTEND', 'DURATION')#
- property location: str | None#
The intended venue for the activity defined by a calendar component.
- Property Parameters:
IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.
- Conformance:
Since RFC 5545, this property can be specified in “VEVENT” or “VTODO” calendar component. RFC 7953 adds this property to “VAVAILABILITY” and “VAVAILABLE”.
- Description:
Specific venues such as conference or meeting rooms may be explicitly specified using this property. An alternate representation may be specified that is a URI that points to directory information with more structured specification of the location. For example, the alternate representation may specify either an LDAP URL RFC 4516 pointing to an LDAP server entry or a CID URL RFC 2392 pointing to a MIME body part containing a Virtual-Information Card (vCard) RFC 2426 for the location.
- name = 'VAVAILABILITY'#
- classmethod new(busy_type: BUSYTYPE | None = None, categories: Sequence[str] = (), comments: list[str] | str | None = None, components: Sequence[Available] | None = (), contacts: list[str] | str | None = None, created: date | None = None, classification: CLASS | None = None, description: str | None = None, end: datetime | None = None, last_modified: date | None = None, location: str | None = None, organizer: vCalAddress | str | None = None, priority: int | None = None, sequence: int | None = None, stamp: date | None = None, start: datetime | None = None, summary: str | None = None, uid: str | uuid.UUID | None = None, url: str | None = None)[source]#
Create a new event with all required properties.
This creates a new Availability in accordance with RFC 7953.
- Parameters:
busy_type – The
busy_type
of the availability.categories – The
categories
of the availability.classification – The
classification
of the availability.comments – The
Component.comments
of the availability.contacts – The
contacts
of the availability.created – The
Component.created
of the availability.description – The
description
of the availability.last_modified – The
Component.last_modified
of the availability.location – The
location
of the availability.organizer – The
organizer
of the availability.sequence – The
sequence
of the availability.stamp – The
Component.stamp
of the availability. If None, this is set to the current time.summary – The
summary
of the availability.uid – The
uid
of the availability. If None, this is set to a newuuid.uuid4()
.url – The
url
of the availability.
- Returns:
- Raises:
InvalidCalendar – If the content is not valid according to RFC 7953.
Warning
As time progresses, we will be stricter with the validation.
- property organizer: vCalAddress | None#
ORGANIZER defines the organizer for a calendar component.
- Property Parameters:
IANA, non-standard, language, common name, directory entry reference, and sent-by property parameters can be specified on this property.
- Conformance:
This property MUST be specified in an iCalendar object that specifies a group-scheduled calendar entity. This property MUST be specified in an iCalendar object that specifies the publication of a calendar user’s busy time. This property MUST NOT be specified in an iCalendar object that specifies only a time zone definition or that defines calendar components that are not group-scheduled components, but are components only on a single user’s calendar.
- Description:
This property is specified within the “VEVENT”, “VTODO”, and “VJOURNAL” calendar components to specify the organizer of a group-scheduled calendar entity. The property is specified within the “VFREEBUSY” calendar component to specify the calendar user requesting the free or busy time. When publishing a “VFREEBUSY” calendar component, the property is used to specify the calendar that the published busy time came from.
The property has the property parameters “CN”, for specifying the common or display name associated with the “Organizer”, “DIR”, for specifying a pointer to the directory information associated with the “Organizer”, “SENT-BY”, for specifying another calendar user that is acting on behalf of the “Organizer”. The non-standard parameters may also be specified on this property. If the “LANGUAGE” property parameter is specified, the identified language applies to the “CN” parameter value.
- property priority: int#
- Conformance:
This property can be specified in “VEVENT” and “VTODO” calendar components according to RFC 5545. RFC 7953 adds this property to “VAVAILABILITY”.
- Description:
This priority is specified as an integer in the range 0 to 9. A value of 0 specifies an undefined priority. A value of 1 is the highest priority. A value of 2 is the second highest priority. Subsequent numbers specify a decreasing ordinal priority. A value of 9 is the lowest priority.
A CUA with a three-level priority scheme of “HIGH”, “MEDIUM”, and “LOW” is mapped into this property such that a property value in the range of 1 to 4 specifies “HIGH” priority. A value of 5 is the normal or “MEDIUM” priority. A value in the range of 6 to 9 is “LOW” priority.
A CUA with a priority schema of “A1”, “A2”, “A3”, “B1”, “B2”, …, “C3” is mapped into this property such that a property value of 1 specifies “A1”, a property value of 2 specifies “A2”, a property value of 3 specifies “A3”, and so forth up to a property value of 9 specifies “C3”.
Other integer values are reserved for future use.
Within a “VEVENT” calendar component, this property specifies a priority for the event. This property may be useful when more than one event is scheduled for a given time period.
Within a “VTODO” calendar component, this property specified a priority for the to-do. This property is useful in prioritizing multiple action items for a given time period.
- required = ('DTSTART', 'DTSTAMP', 'UID')#
- property sequence: int#
This property defines the revision sequence number of the calendar component within a sequence of revisions.
- Value Type:
INTEGER
- Property Parameters:
IANA and non-standard property parameters can be specified on this property.
- Conformance:
The property can be specified in “VEVENT”, “VTODO”, or “VJOURNAL” calendar component.
- Description:
When a calendar component is created, its sequence number is 0. It is monotonically incremented by the “Organizer’s” CUA each time the “Organizer” makes a significant revision to the calendar component.
The “Organizer” includes this property in an iCalendar object that it sends to an “Attendee” to specify the current version of the calendar component.
The “Attendee” includes this property in an iCalendar object that it sends to the “Organizer” to specify the version of the calendar component to which the “Attendee” is referring.
A change to the sequence number is not the mechanism that an “Organizer” uses to request a response from the “Attendees”. The “RSVP” parameter on the “ATTENDEE” property is used by the “Organizer” to indicate that a response from the “Attendees” is requested.
Recurrence instances of a recurring component MAY have different sequence numbers.
Examples
The following is an example of this property for a calendar component that was just created by the “Organizer”:
>>> from icalendar import Event >>> event = Event() >>> event.sequence 0
The following is an example of this property for a calendar component that has been revised 10 different times by the “Organizer”:
>>> from icalendar import Calendar >>> calendar = Calendar.example("issue_156_RDATE_with_PERIOD_TZID_khal") >>> event = calendar.events[0] >>> event.sequence 10
- singletons = ('DTSTAMP', 'UID', 'BUSYTYPE', 'CLASS', 'CREATED', 'DESCRIPTION', 'DTSTART', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PRIORITY', 'SEQUENCE', 'SUMMARY', 'URL', 'DTEND', 'DURATION')#
- property start: datetime | None#
The DTSTART property. datetime in UTC
All values will be converted to a datetime in UTC. Start of the component.
This is almost the same as
Event.DTSTART
with one exception: The values MUST have a timezone and DATE is not allowed.- Description:
RFC 7953: If specified, the “DTSTART” and “DTEND” properties in “VAVAILABILITY” components and “AVAILABLE” subcomponents MUST be “DATE-TIME” values specified as either the date with UTC time or the date with local time and a time zone reference.
- property summary: str | None#
SUMMARY defines a short summary or subject for the calendar component.
- Property Parameters:
IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.
- Conformance:
The property can be specified in “VEVENT”, “VTODO”, “VJOURNAL”, or “VALARM” calendar components.
- Description:
This property is used in the “VEVENT”, “VTODO”, and “VJOURNAL” calendar components to capture a short, one-line summary about the activity or journal entry.
This property is used in the “VALARM” calendar component to capture the subject of an EMAIL category of alarm.
Examples
The following is an example of this property:
SUMMARY:Department Party
- property url: str#
A Uniform Resource Locator (URL) associated with the iCalendar object.
- Description:
This property may be used in a calendar component to convey a location where a more dynamic rendition of the calendar information associated with the calendar component can be found. This memo does not attempt to standardize the form of the URI, nor the format of the resource pointed to by the property value. If the URL property and Content-Location MIME header are both specified, they MUST point to the same resource.
- Conformance:
This property can be specified once in the “VEVENT”, “VTODO”, “VJOURNAL”, or “VFREEBUSY” calendar components. Since RFC 7986, this property can also be defined on a “VCALENDAR”.
Example
The following is an example of this property:
URL:http://example.com/pub/calendars/jsmith/mytime.ics