icalendar.timezone package#
This package contains all functionality for timezones.
- class icalendar.timezone.TZP(provider='zoneinfo')[source]#
Bases:
objectThis 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)[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)[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.
- Return type:
- create_timezone(timezone_component)[source]#
Create a timezone from a timezone component.
This component will not be cached.
- localize_utc(dt)[source]#
Return the datetime in UTC.
If the datetime has no timezone, set UTC as its timezone.
- Return type:
- icalendar.timezone.tzid_from_tzinfo(tzinfo)[source]#
Retrieve the timezone id from the tzinfo object.
Some timezones are equivalent. Thus, we might return one ID that is equivalent to others.
- icalendar.timezone.tzids_from_tzinfo(tzinfo)[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.