icalendar.cal.timezone module#
RFC 5545 components for timezone information.
- class icalendar.cal.timezone.Timezone(*args, **kwargs)[source]#
Bases:
ComponentA "VTIMEZONE" calendar component is a grouping of component properties that defines a time zone. It is used to describe the way in which a time zone changes its offset from UTC over time.
Examples
Get the example Timezone.
>>> from icalendar import Timezone >>> timezone = Timezone.example() >>> print(timezone["TZID"]) custom_Pacific/Fiji >>> len(timezone.subcomponents) 5
- DEFAULT_FIRST_DATE = datetime.date(1970, 1, 1)#
- DEFAULT_LAST_DATE = datetime.date(2038, 1, 1)#
- canonical_order = ('TZID',)#
- property daylight: list[TimezoneDaylight]#
The DAYLIGHT subcomponents as a list.
These are for the daylight saving time.
- classmethod example(name='pacific_fiji')[source]#
Return the timezone example with the given name.
Example
>>> from icalendar import Timezone >>> timezone = Timezone.example() >>> print(timezone["TZID"]) custom_Pacific/Fiji
- Return type:
- classmethod from_tzid(tzid, tzp=TZP('zoneinfo'), first_date=datetime.date(1970, 1, 1), last_date=datetime.date(2038, 1, 1))[source]#
Create a VTIMEZONE from a tzid, such as
"Europe/Berlin".- Parameters:
- Return type:
- Returns:
A VTIMEZONE component for the given tzid.
- Raises:
ValueError – If the tzid is unknown.
Example
>>> from icalendar import Timezone >>> tz = Timezone.from_tzid("Europe/Berlin") >>> print(tz.to_ical()[:36]) BEGIN:VTIMEZONE TZID:Europe/Berlin
Note
This can take some time. Please cache the results.
- classmethod from_tzinfo(timezone, tzid=None, first_date=datetime.date(1970, 1, 1), last_date=datetime.date(2038, 1, 1))[source]#
Return a VTIMEZONE component from a timezone object.
Calculate offsets from a pytz, zoneinfo, or other timezone object.
- Parameters:
- Returns:
The
VTIMEZONEcomponent fortimezone.- Return type:
- Raises:
ValueError – If
tzidis None and cannot be derived fromtimezone.
Note
This can take some time. Please cache the results.
- get_transitions()[source]#
Return a tuple of (transition_times, transition_info)
transition_times = [datetime, …]
transition_info = [(TZOFFSETTO, dts_offset, tzname)]
- name: ClassVar[str | None] = 'VTIMEZONE'#
The name of the component.
This is defined in each component class.
Example
>>> from icalendar import Calendar >>> cal = Calendar.new() >>> cal.name 'VCALENDAR'
- singletons: ClassVar[tuple[()]] = ('TZID', 'LAST-MODIFIED', 'TZURL')#
These properties must appear only once.
- property standard: list[TimezoneStandard]#
The STANDARD subcomponents as a list.
- subcomponents: list[TimezoneStandard | TimezoneDaylight]#
All subcomponents of this component.
- class icalendar.cal.timezone.TimezoneDaylight(*args, **kwargs)[source]#
Bases:
ComponentThe "DAYLIGHT" sub-component of "VTIMEZONE" defines the daylight saving time offset from UTC for a time zone. It represents a time zone's daylight saving time, typically used during summer months in locations that observe Daylight Saving Time.
- property DTSTART: datetime | None#
The DTSTART property.
- The mandatory "DTSTART" property gives the effective onset date
and local time for the time zone sub-component definition. "DTSTART" in this usage MUST be specified as a date with a local time value.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property TZOFFSETFROM: timedelta | None#
The TZOFFSETFROM property.
- The mandatory "TZOFFSETFROM" property gives the UTC offset that is
in use when the onset of this time zone observance begins. "TZOFFSETFROM" is combined with "DTSTART" to define the effective onset for the time zone sub-component definition. For example, the following represents the time at which the observance of Standard Time took effect in Fall 1967 for New York City:
DTSTART:19671029T020000 TZOFFSETFROM:-0400
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property TZOFFSETTO: timedelta | None#
The TZOFFSETTO property.
- The mandatory "TZOFFSETTO" property gives the UTC offset for the
time zone sub-component (Standard Time or Daylight Saving Time) when this observance is in use.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- multiple: ClassVar[tuple[()]] = ('COMMENT', 'RDATE', 'TZNAME', 'RRULE', 'EXDATE')#
These properties may occur more than once.
- name: ClassVar[str | None] = 'DAYLIGHT'#
The name of the component.
This is defined in each component class.
Example
>>> from icalendar import Calendar >>> cal = Calendar.new() >>> cal.name 'VCALENDAR'
- class icalendar.cal.timezone.TimezoneStandard(*args, **kwargs)[source]#
Bases:
ComponentThe "STANDARD" sub-component of "VTIMEZONE" defines the standard time offset from UTC for a time zone. It represents a time zone's standard time, typically used during winter months in locations that observe Daylight Saving Time.
- property DTSTART: datetime | None#
The DTSTART property.
- The mandatory "DTSTART" property gives the effective onset date
and local time for the time zone sub-component definition. "DTSTART" in this usage MUST be specified as a date with a local time value.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property TZOFFSETFROM: timedelta | None#
The TZOFFSETFROM property.
- The mandatory "TZOFFSETFROM" property gives the UTC offset that is
in use when the onset of this time zone observance begins. "TZOFFSETFROM" is combined with "DTSTART" to define the effective onset for the time zone sub-component definition. For example, the following represents the time at which the observance of Standard Time took effect in Fall 1967 for New York City:
DTSTART:19671029T020000 TZOFFSETFROM:-0400
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- property TZOFFSETTO: timedelta | None#
The TZOFFSETTO property.
- The mandatory "TZOFFSETTO" property gives the UTC offset for the
time zone sub-component (Standard Time or Daylight Saving Time) when this observance is in use.
To delete the value, either use
delor set it toNone.- Raises:
InvalidCalendar – if the attribute has invalid values.
- multiple: ClassVar[tuple[()]] = ('COMMENT', 'RDATE', 'TZNAME', 'RRULE', 'EXDATE')#
These properties may occur more than once.
- name: ClassVar[str | None] = 'STANDARD'#
The name of the component.
This is defined in each component class.
Example
>>> from icalendar import Calendar >>> cal = Calendar.new() >>> cal.name 'VCALENDAR'