icalendar.timezone package#
This package contains all functionality for timezones.
- class icalendar.timezone.TZP(provider: str | TZProvider = 'zoneinfo')[source]#
Bases:
object
This is the timezone provider proxy.
If you would like to have another timezone implementation, you can create a new one and pass it to this proxy. All of icalendar will then use this timezone implementation.
- cache_timezone_component(timezone_component: Timezone.Timezone) None [source]#
Cache the timezone that is created from a timezone component if it is not already known.
This can influence the result from timezone(): Once cached, the custom timezone is returned from timezone().
- clean_timezone_id(tzid: str) str [source]#
Return a clean version of the timezone id.
Timezone ids can be a bit unclean, starting with a / for example. Internally, we should use this to identify timezones.
- create_timezone(timezone_component: Timezone.Timezone) datetime.tzinfo [source]#
Create a timezone from a timezone component.
This component will not be cached.
- fix_rrule_until(rrule: rrule, ical_rrule: prop.vRecur) None [source]#
Make sure the until value works.
- localize(dt: datetime.date, tz: datetime.tzinfo | str | None) datetime.datetime [source]#
Localize a datetime to a timezone.
- localize_utc(dt: datetime.date) datetime.datetime [source]#
Return the datetime in UTC.
If the datetime has no timezone, set UTC as its timezone.
- timezone(tz_id: str) datetime.tzinfo | None [source]#
Return a timezone with an id or None if we cannot find it.
- use(provider: str | TZProvider)[source]#
Switch to a different timezone provider.
- icalendar.timezone.tzid_from_dt(dt: datetime) str | None [source]#
Retrieve the timezone id from the datetime object.
- icalendar.timezone.tzid_from_tzinfo(tzinfo: tzinfo | None) str | None [source]#
Retrieve the timezone id from the tzinfo object.
Some timezones are equivalent. Thus, we might return one ID that is equivelant to others.
- icalendar.timezone.tzids_from_tzinfo(tzinfo: tzinfo | None) tuple[str] [source]#
Get several timezone ids if we can identify the timezone.
>>> import zoneinfo >>> from icalendar.timezone.tzid import tzids_from_tzinfo >>> tzids_from_tzinfo(zoneinfo.ZoneInfo("Arctic/Longyearbyen")) ('Arctic/Longyearbyen', 'Atlantic/Jan_Mayen', 'Europe/Berlin', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Oslo', 'Europe/Stockholm', 'Europe/Vienna') >>> from dateutil.tz import gettz >>> tzids_from_tzinfo(gettz("Europe/Berlin")) ('Europe/Berlin', 'Arctic/Longyearbyen', 'Atlantic/Jan_Mayen', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Oslo', 'Europe/Stockholm', 'Europe/Vienna')
- icalendar.timezone.use_pytz()[source]#
Use pytz as the implementation that looks up and creates timezones.
- icalendar.timezone.use_zoneinfo()[source]#
Use zoneinfo as the implementation that looks up and creates timezones.
Submodules#
- icalendar.timezone.equivalent_timezone_ids module
- icalendar.timezone.equivalent_timezone_ids_result module
- icalendar.timezone.provider module
- icalendar.timezone.pytz module
- icalendar.timezone.tzid module
- icalendar.timezone.tzp module
- icalendar.timezone.windows_to_olson module
- icalendar.timezone.zoneinfo module