icalendar.cal.event module#
RFC 5545 VEVENT component.
- class icalendar.cal.event.Event(*args, **kwargs)[source]#
Bases:
ComponentA grouping of component properties that describe an event.
- Description:
A "VEVENT" calendar component is a grouping of component properties, possibly including "VALARM" calendar components, that represents a scheduled amount of time on a calendar. For example, it can be an activity; such as a one-hour long, department meeting from 8:00 AM to 9:00 AM, tomorrow. Generally, an event will take up time on an individual calendar. Hence, the event will appear as an opaque interval in a search for busy time. Alternately, the event can have its Time Transparency set to "TRANSPARENT" in order to prevent blocking of the event in searches for busy time.
The "VEVENT" is also the calendar component used to specify an anniversary or daily reminder within a calendar. These events have a DATE value type for the "DTSTART" property instead of the default value type of DATE-TIME. If such a "VEVENT" has a "DTEND" property, it MUST be specified as a DATE value also. The anniversary type of "VEVENT" can span more than one date (i.e., "DTEND" property value is set to a calendar date after the "DTSTART" property value). If such a "VEVENT" has a "DURATION" property, it MUST be specified as a "dur-day" or "dur-week" value.
The "DTSTART" property for a "VEVENT" specifies the inclusive start of the event. For recurring events, it also specifies the very first instance in the recurrence set. The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE value type but no "DTEND" nor "DURATION" property, the event's duration is taken to be one day. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME value type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.
The "VEVENT" calendar component cannot be nested within another calendar component. However, "VEVENT" calendar components can be related to each other or to a "VTODO" or to a "VJOURNAL" calendar component with the "RELATED-TO" property.
Examples
The following is an example of the "VEVENT" calendar component used to represent a meeting that will also be opaque to searches for busy time:
BEGIN:VEVENT UID:19970901T130000Z-123401@example.com DTSTAMP:19970901T130000Z DTSTART:19970903T163000Z DTEND:19970903T190000Z SUMMARY:Annual Employee Review CLASS:PRIVATE CATEGORIES:BUSINESS,HUMAN RESOURCES END:VEVENT
The following is an example of the "VEVENT" calendar component used to represent a reminder that will not be opaque, but rather transparent, to searches for busy time:
BEGIN:VEVENT UID:19970901T130000Z-123402@example.com DTSTAMP:19970901T130000Z DTSTART:19970401T163000Z DTEND:19970402T010000Z SUMMARY:Laurel is in sensitivity awareness class. CLASS:PUBLIC CATEGORIES:BUSINESS,HUMAN RESOURCES TRANSP:TRANSPARENT END:VEVENT
The following is an example of the "VEVENT" calendar component used to represent an anniversary that will occur annually:
BEGIN:VEVENT UID:19970901T130000Z-123403@example.com DTSTAMP:19970901T130000Z DTSTART;VALUE=DATE:19971102 SUMMARY:Our Blissful Anniversary TRANSP:TRANSPARENT CLASS:CONFIDENTIAL CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION RRULE:FREQ=YEARLY END:VEVENT
The following is an example of the "VEVENT" calendar component used to represent a multi-day event scheduled from June 28th, 2007 to July 8th, 2007 inclusively. Note that the "DTEND" property is set to July 9th, 2007, since the "DTEND" property specifies the non-inclusive end of the event.
BEGIN:VEVENT UID:20070423T123432Z-541111@example.com DTSTAMP:20070423T123432Z DTSTART;VALUE=DATE:20070628 DTEND;VALUE=DATE:20070709 SUMMARY:Festival International de Jazz de Montreal TRANSP:TRANSPARENT END:VEVENT
Create a new Event:
>>> from icalendar import Event >>> from datetime import datetime >>> event = Event.new(start=datetime(2021, 1, 1, 12, 30, 0)) >>> print(event.to_ical()) BEGIN:VEVENT DTSTART:20210101T123000 DTSTAMP:20250517T080612Z UID:d755cef5-2311-46ed-a0e1-6733c9e15c63 END:VEVENT
Get the example Event:
>>> from icalendar import Event >>> event = Event.example() >>> print(event["SUMMARY"]) Meeting >>> len(event.alarms.times) 2
- property DTEND: date | None#
The DTEND property.
The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property DTSTART: date | None#
The DTSTART property.
The "DTSTART" property for a "VEVENT" specifies the inclusive start of the event.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property DURATION: timedelta | None#
The DURATION property.
The "DTSTART" property for a "VEVENT" specifies the inclusive start of the VEVENT. The "DURATION" property in conjunction with the DTSTART property for a "VEVENT" calendar component specifies the non-inclusive end of the event.
If you would like to calculate the duration of a VEVENT, do not use this. Instead use the duration property (lower case).
- property RECURRENCE_ID: date | datetime | None#
The RECURRENCE-ID property.
Identify a specific occurrence of a recurring calendar object.
This property is used together with
UIDandSEQUENCEto refer to one particular instance in a recurrence set. The value is the original start date or datetime of that instance, not the rescheduled time.The value is usually a DATE-TIME and must use the same value type as the
DTSTARTproperty in the same component. A DATE value may be used for all-day items instead.This property corresponds to
RECURRENCE-IDas defined in RFC 5545 and may appear in recurringVEVENT,VTODO, andVJOURNALcomponents.To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar: if the attribute has invalid values.
- property REQUEST_STATUS: PropertyListView#
This property defines the status code returned for a scheduling request.
You can assign a single string, a list of strings, or
Noneto this property. The property stores astras-is. AssigningNoneor an empty list removes all REQUEST-STATUS values, as does deleting the property.The value consists of a short return status code component, a longer return status description component, and optionally a status-specific data component, separated by semicolons (statcode;statdesc[;extdata]). The return status components are defined in RFC 5545 Section 3.8.8.3.
The REQUEST-STATUS property can be specified in the following icalendar components as
REQUEST_STATUS.Note
When you assign a list to this property, the returned list is the same object stored in the component. Modifying it (
append(),extend(),remove(), item assignment, ordel) changes what the component stores.However, if you assign a single string value to this property, the returned list is a temporary copy, and changes to this list don't affect the component.
- Parameters:
request_status (str | list[str] | None) – Either a single status string, a list of status strings, or
Noneto set the component's status code returned for a scheduling request.
Example
Add a request status to an event:
>>> from icalendar import Event >>> event = Event.new(request_status="2.0;Success") >>> event.REQUEST_STATUS == ["2.0;Success"] True
vRequestStatusdefines properties for ease of use:>>> request_status = event.REQUEST_STATUS[0] >>> request_status.code (2, 0) >>> request_status.description 'Success'
- property RESOURCES: PropertyListView#
This property defines resources for a calendar component.
You can assign a single string, a list of strings, or
Noneto this property. The property stores astras-is. AssigningNoneor an empty list removes all RESOURCES values, as does deleting the property.The value is a comma-separated list of resources, such as equipment, facilities, or other things that the component needs. Each item of the list becomes its own RESOURCES property value. See RFC 5545 Section 3.8.1.10 for the specification.
The RESOURCES property can be specified in the following icalendar components as
resourcesusing the component'snew()constructor.- Parameters:
resources (str | list[str] | None) – Either a single resource string, a list of resource strings, or
Noneto set the component's resources.
Note
When you assign a list to this property, the returned list is the same object stored in the component. Modifying it (
append(),extend(),remove(), item assignment, ordel) changes what the component stores.However, if you assign a single string value to this property, the returned list is a temporary copy, and changes to this list don't affect the component.
Example
Add resources to an event:
>>> from icalendar import Event >>> event = Event.new(resources=["EASEL", "PROJECTOR", "VCR"]) >>> event.RESOURCES == ["EASEL", "PROJECTOR", "VCR"] True
- property X_MOZ_LASTACK: datetime | None#
The
X-MOZ-LASTACKproperty as adatetimein UTC.Thunderbird: Alarms before this time are acknowledged.
- property X_MOZ_SNOOZE_TIME: datetime | None#
The
X-MOZ-SNOOZE-TIMEproperty as adatetimein UTC.Thunderbird: Alarms before this time are snoozed.
- property alarms: Alarms#
Compute the alarm times for this component.
>>> from icalendar import Event >>> event = Event.example("rfc_9074_example_1") >>> len(event.alarms.times) 1 >>> alarm_time = event.alarms.times[0] >>> alarm_time.trigger # The time when the alarm pops up datetime.datetime(2021, 3, 2, 10, 15, tzinfo=ZoneInfo(key='America/New_York')) >>> alarm_time.is_active() # This alarm has not been acknowledged True
Note that this only uses DTSTART and DTEND, but ignores RDATE, EXDATE, and RRULE properties.
- property attachments: list[vUri | vBinary]#
This property defines the attachments for a component.
Setting this property replaces all existing attachments. A
stris converted tovUri, andbytesis converted tovBinary. Values that are alreadyvUriorvBinaryare stored unchanged, so their parameters are preserved. SettingNoneor an empty list removes all attachments, as does deleting the property.- Parameters:
attachments (str | bytes | vUri | vBinary | list | None) – A single attachment, or a list of attachments to set. Accepts
str,bytes,vUri, andvBinary, individually or mixed together in a list.
Example
Attach a URI to an event, then replace it with a URI and inline binary data together:
>>> from icalendar import Event, vUri, vBinary >>> event = Event() >>> event.attachments [] >>> event.attachments = ["https://example.com/agenda.pdf"] >>> print(event.to_ical().decode()) BEGIN:VEVENT ATTACH:https://example.com/agenda.pdf END:VEVENT >>> event.attachments = [ ... vUri( ... "https://example.com/agenda.pdf", ... params={"FMTTYPE": "application/pdf"}, ... ), ... vBinary(b"image-data", params={"FMTTYPE": "image/png"},), ... ] >>> len(event.attachments) 2
Note
An alarm as an audio action must not contain more than one attachment.
List modifications do not modify the component. Methods such as
append(),extend(), andremove(), as well as item assignment, act on a copy. Assign the list back to the property, or useComponent.addwith a typed value instead.See also
RFC 5545 Section 3.8.1.1 for the definition of the
ATTACHproperty.
- property attendees: list[vCalAddress]#
ATTENDEE defines one or more "Attendees" within a calendar component.
- Conformance:
This property MUST be specified in an iCalendar object that specifies a group-scheduled calendar entity. This property MUST NOT be specified in an iCalendar object when publishing the calendar information (e.g., NOT in an iCalendar object that specifies the publication of a calendar user's busy time, event, to-do, or journal). This property is not 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 MUST only be specified within calendar components to specify participants, non-participants, and the chair of a group-scheduled calendar entity. The property is specified within an "EMAIL" category of the "VALARM" calendar component to specify an email address that is to receive the email type of iCalendar alarm.
Examples
Assign one or more attendee email addresses directly. Strings are converted to
vCalAddressobjects and receive amailto:prefix when needed.>>> from icalendar import Event >>> event = Event() >>> event.attendees = [ ... "me@my-domain.com", ... "mailto:you@my-domain.com", ... ] >>> event.attendees[0] vCalAddress('mailto:me@my-domain.com') >>> event.attendees[1] vCalAddress('mailto:you@my-domain.com') >>> print(event.to_ical()) BEGIN:VEVENT ATTENDEE:mailto:me@my-domain.com ATTENDEE:mailto:you@my-domain.com END:VEVENT
Use
vCalAddress.newwhen an attendee needs parameters such asCN,ROLE, orRSVP.>>> from icalendar import vCalAddress >>> event.attendees = [ ... vCalAddress.new( ... "chair@example.com", ... cn="Meeting Chair", ... role="CHAIR", ... rsvp=True, ... ) ... ]
- Setter accepts:
Sequence[vCalAddress|str] |vCalAddress|str|None
- canonical_order = ('SUMMARY', 'DTSTART', 'DTEND', 'DURATION', 'DTSTAMP', 'UID', 'RECURRENCE-ID', 'SEQUENCE', 'RRULE', 'RDATE', 'EXDATE')#
- property categories: list[str]#
This property defines the categories for a component.
The categories property is used to specify categories or subtypes of the calendar component. The categories are useful to search for a calendar component of a particular type and category.
Within the calendar components, specify categories as a list of strings. You can get, set, and delete categories for a component.
This property can be used in icalendar through its Python attributes of:
The categories property for
AvailableandAvailabilitycomplies with RFC 7953 Section 3.1, forEvent,Journal, andTodowith RFC 5545 Section 3.8.1.2, and forCalendarwith RFC 7986 Section 5.6.Note
At present, icalendar doesn't take the LANGUAGE parameter as defined in RFC 5545 Section 3.2.10 into account.
Example
Create an event, add categories to it, print its ical representation, append another category, and finally compare the result against its expected value.
>>> 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
See also
Component.concepts
- property classification: StrEnum | str#
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 color: str#
This property specifies a color used for displaying the component.
This implements RFC 7986
COLORproperty.- Property Parameters:
IANA and non-standard property parameters can be specified on this property.
- Conformance:
This property can be specified once in an iCalendar object or in
VEVENT,VTODO, orVJOURNALcalendar components.- Description:
This property specifies a color that clients MAY use when presenting the relevant data to a user. Typically, this would appear as the "background" color of events or tasks. The value is a case-insensitive color name taken from the CSS3 set of names, defined in Section 4.3 of W3C.REC-css3-color-20110607.
Example
"turquoise","#ffffff">>> from icalendar import Todo >>> todo = Todo() >>> todo.color = "green" >>> print(todo.to_ical()) BEGIN:VTODO COLOR:green END:VTODO
- property contacts: list[str]#
Contact information associated with a calendar component.
The contact property holds free-text information for reaching the person or organization responsible in a component, such as a name, phone number, or a reference to more detailed contact data. Calendar clients surface it so attendees know who to contact about the event or task.
This property is defined in RFC 5545 Section 3.8.4.2 and may appear on a
VEVENT,VTODO,VJOURNAL, orVFREEBUSYcomponent. For availability components it is defined in RFC 7953 and may appear on aVAVAILABILITYorVAVAILABLEcomponent. An alternate representation may point to a URI, for example, a vCard per RFC 2426, via theALTREPparameter.You can get, set, append, and delete contacts on a component. The value is a list of strings; each string is one contact entry.
Example
Add a contact to an event and then read it back.
>>> from icalendar import Event >>> event = Event() >>> event.add("CONTACT", "Jim Dolittle, ABC Industries, +1-919-555-1234") >>> [str(c) for c in event.contacts] ['Jim Dolittle, ABC Industries, +1-919-555-1234'] >>> str(event.contacts[0]) '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#
The duration of the VEVENT.
Returns the DURATION property if set, otherwise calculated from start and end. When setting duration, the end time is automatically calculated from start + duration.
You can set the duration to automatically adjust the end time while keeping start locked.
Setting the duration will do the following.
Keep the start time locked (unchanged)
Adjust the end time to start + duration
Remove any existing DTEND property
Set the DURATION property
- property end: date | datetime#
The end of the event.
Invalid values raise an
InvalidCalendarerror. If there is no end, we also raise anIncompleteComponenterror.
- classmethod example(name='rfc_9074_example_3')[source]#
Return the event example with the given name.
Example
>>> from icalendar import Event >>> event = Event.example() >>> print(event["SUMMARY"]) Meeting
- Return type:
- ignore_exceptions: ClassVar[bool] = True#
Whether or not to ignore exceptions when parsing.
If
True, and this component can't be parsed, then it will silently ignore it, rather than let the exception propagate upwards.
- 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.
- multiple: ClassVar[tuple[()]] = ('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'EXDATE', 'REQUEST-STATUS', 'RELATED', 'RESOURCES', 'RDATE', 'RRULE')#
These properties may occur more than once.
- name: ClassVar[str | None] = 'VEVENT'#
The name of the component.
This is defined in each component class.
Example
>>> from icalendar import Calendar >>> cal = Calendar.new() >>> cal.name 'VCALENDAR'
- classmethod new(attachments=None, attendees=None, categories=(), classification=None, color=None, comments=None, concepts=None, conferences=None, contacts=None, created=None, description=None, end=None, last_modified=None, links=None, location=None, organizer=None, priority=None, recurrence_id=None, refids=None, related_to=None, request_status=None, resources=None, sequence=None, stamp=None, start=None, status=None, subcomponents=None, transparency=None, summary=None, uid=None, url=None)[source]#
Create a new event with the required properties of
stampanduid.This creates a new
Eventin accordance with RFC 5545 Section 3.6.1.- Parameters:
attachments (
str|bytes|vUri|vBinary|list[str|bytes|vUri|vBinary] |None) – Theattachmentsof the event.attendees (
Sequence[vCalAddress|str] |vCalAddress|str|None) – Theattendeesof the event.categories (
Sequence[str]) – Thecategoriesof the event.classification (
CLASS|None) – Theclassificationof the event.comments (
list[str] |str|None) – Thecommentsof the event.concepts (
list[vUri|str] |str|vUri|None) – Theconceptsof the event.conferences (
list[Conference] |None) – Theconferencesof the event.description (
str|None) – Thedescriptionof the event.last_modified (
date|None) – Thelast_modifiedof the event.links (
str|vUri|vUid|vXmlReference|list[str|vUri|vUid|vXmlReference] |None) – Thelinksof the event.organizer (
vCalAddress|str|None) – Theorganizerof the event.recurrence_id (
date|datetime|None) – TheRECURRENCE_IDof the event.related_to (
str|vText|vUri|vUid|list[str|vText|vUri|vUid] |None) –related_toof the event.request_status (
list[str] |str|None) – TheREQUEST_STATUSof the event.resources (
list[str] |str|None) – TheRESOURCESof the event.stamp (
date|None) – Thestampof the event. IfNone, this is set to the current UTC time.subcomponents (
Iterable[Component] |None) – The subcomponents of the event.transparency (
TRANSP|None) – Thetransparencyof the event.uid (
str|UUID|None) – Theuidof the event. IfNone, this is set to a newuuid.uuid4().
- Return type:
- Returns:
- Raises:
InvalidCalendar – If the content is not valid according to RFC 5545.
Warning
As time progresses, we will be stricter with the validation.
- 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.
- Raises:
- TypeError: If the value is not an
int. Booleans are rejected, too, even though
boolsubclassesint.
~icalendar.error.InvalidCalendar: If the value is negative.
- TypeError: If the value is not an
Changed in version 7.3.0: Negative values are no longer accepted.
- 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
- Raises:
- TypeError: If the value is not an
int. Booleans are rejected, too, even though
boolsubclassesint.
~icalendar.error.InvalidCalendar: If the value is negative.
- TypeError: If the value is not an
Changed in version 7.3.0: Negative values are no longer accepted.
- set_duration(duration, locked='start')[source]#
Set the duration of the event relative to either start or end.
- set_end(end, locked='start')[source]#
Set the end of the component, keeping either the start or the duration same.
- singletons: ClassVar[tuple[()]] = ('CLASS', 'CREATED', 'COLOR', 'DESCRIPTION', 'DTSTART', 'GEO', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PRIORITY', 'DTSTAMP', 'SEQUENCE', 'STATUS', 'SUMMARY', 'TRANSP', 'URL', 'RECURRENCE-ID', 'DTEND', 'DURATION', 'UID')#
These properties must appear only once.
- property start: date | datetime#
The start of the event.
Invalid values raise an
InvalidCalendar. If there is no start, we also raise anIncompleteComponenterror.You can get the start, end and duration of an event as follows:
>>> from datetime import datetime >>> from icalendar import Event >>> event = Event() >>> event.start = datetime(2021, 1, 1, 12) >>> event.end = datetime(2021, 1, 1, 12, 30) # 30 minutes >>> event.duration # 1800 seconds == 30 minutes datetime.timedelta(seconds=1800) >>> print(event.to_ical()) BEGIN:VEVENT DTSTART:20210101T120000 DTEND:20210101T123000 END:VEVENT
- property status: StrEnum | str#
STATUS defines the overall status or confirmation for the calendar component.
In a group-scheduled calendar component, this property is used by the Organizer to provide information about the status of an
Event,Todo, orJournal.The default value is
"".Possible values for
Eventinclude the following:Possible values for
Todoinclude the following:Possible values for
Journalinclude the following:Changed in version 0.0.0: Added two task statuses according to RFC 10051 Section 11.2:
PENDINGfor a task that has been accepted but has not started, andFAILEDfor a task that has failed.- Returns:
- Setter accepts:
- 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 transparency: StrEnum | str#
TRANSP defines whether or not an event is transparent to busy time searches.
- Returns:
- Description:
Time Transparency is the characteristic of an event that determines whether it appears to consume time on a calendar. Events that consume actual time for the individual or resource associated with the calendar SHOULD be recorded as OPAQUE, allowing them to be detected by free/busy time searches. Other events, which do not take up the individual's (or resource's) time SHOULD be recorded as TRANSPARENT, making them invisible to free/ busy time searches.
- property uid: str#
UID specifies the persistent, globally unique identifier for a component.
We recommend using
uuid.uuid4()to generate new values.- Returns:
The value of the UID property as a string or
""if no value is set.
- Description:
The "UID" itself MUST be a globally unique identifier. The generator of the identifier MUST guarantee that the identifier is unique.
This is the method for correlating scheduling messages with the referenced "VEVENT", "VTODO", or "VJOURNAL" calendar component. The full range of calendar components specified by a recurrence set is referenced by referring to just the "UID" property value corresponding to the calendar component. The "RECURRENCE-ID" property allows the reference to an individual instance within the recurrence set.
This property is an important method for group-scheduling applications to match requests with later replies, modifications, or deletion requests. Calendaring and scheduling applications MUST generate this property in "VEVENT", "VTODO", and "VJOURNAL" calendar components to assure interoperability with other group- scheduling applications. This identifier is created by the calendar system that generates an iCalendar object.
Implementations MUST be able to receive and persist values of at least 255 octets for this property, but they MUST NOT truncate values in the middle of a UTF-8 multi-octet sequence.
RFC 7986 states that UID can be used, for example, to identify duplicate calendar streams that a client may have been given access to. It can be used in conjunction with the "LAST-MODIFIED" property also specified on the "VCALENDAR" object to identify the most recent version of a calendar.
- Conformance:
RFC 5545 states that the "UID" property can be specified on "VEVENT", "VTODO", and "VJOURNAL" calendar components. RFC 7986 modifies the definition of the "UID" property to allow it to be defined in an iCalendar object. RFC 9074 adds a "UID" property to "VALARM" components to allow a unique identifier to be specified. The value of this property can then be used to refer uniquely to the "VALARM" component.
This property can be specified once only.
- Security:
RFC 7986 states that UID values MUST NOT include any data that might identify a user, host, domain, or any other security- or privacy-sensitive information. It is RECOMMENDED that calendar user agents now generate "UID" values that are hex-encoded random Universally Unique Identifier (UUID) values as defined in Sections 4.4 and 4.5 of RFC 4122. You can use the
uuidmodule to generate new UUIDs.- Compatibility:
For Alarms,
X-ALARMUIDis also considered.
Examples
The following is an example of such a property value:
5FC53010-1267-4F8E-BC28-1D7AE55A7C99.Set the UID of a calendar:
>>> from icalendar import Calendar >>> from uuid import uuid4 >>> calendar = Calendar() >>> calendar.uid = uuid4() >>> print(calendar.to_ical()) BEGIN:VCALENDAR UID:d755cef5-2311-46ed-a0e1-6733c9e15c63 END:VCALENDAR
- property url: str#
A Uniform Resource Locator (URL) associated with a calendar component.
This property specifies a URI where a more dynamic rendition of the calendar information can be found. It is commonly used to reference related resources or provide additional information about the component.
According to RFC 5545 Section 3.8.4.6, this property can be specified once in "VEVENT", "VTODO", "VJOURNAL", or "VFREEBUSY" calendar components. Since RFC 7986 Section 5.5, this property can also be defined on a "VCALENDAR". RFC 7953 Section 3.1 allows this property in "VAVAILABILITY" components.
This property may be used in a calendar component to convey a location where a more dynamic rendition of the calendar information can be found. If both the URL property and Content-Location MIME header are specified, they MUST point to the same resource.
This differs from the SOURCE property, which identifies where calendar data can be refreshed from, whereas URL provides an alternative representation of the current calendar data.
Examples
Set a URL for an event that references additional information:
>>> from icalendar import Event >>> event = Event() >>> event.add('url', 'http://example.com/events/meeting-2025') >>> print(event.to_ical().decode('utf-8')) BEGIN:VEVENT URL:http://example.com/events/meeting-2025 END:VEVENT
Set a URL for a calendar:
>>> from icalendar import Calendar >>> calendar = Calendar() >>> calendar.add('url', 'http://example.com/pub/calendars/jsmith/mytime.ics') >>> print(calendar.to_ical().decode('utf-8')) BEGIN:VCALENDAR URL:http://example.com/pub/calendars/jsmith/mytime.ics END:VCALENDAR
See also
sourcefor specifying from where calendar data can be refreshed.icalendar implementations: