icalendar.timezone.tzp module#
- class icalendar.timezone.tzp.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.
Create a new timezone implementation proxy.
- 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().
- Return type:
- 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.
- Return type:
- localize(dt, tz)[source]#
Localize a date, datetime or time to a timezone.
- Overloads:
Use
tz=Noneto remove the timezone.- Returns:
A localized
datetime.datetimewhen adatetime.datetimeis given.A localized
datetime.datetimeat midnight when adatetime.dateis given.A localized
datetime.timewhen adatetime.timeis given.
- localize_utc(dt)[source]#
Return the value in UTC.
If the value has no timezone, set UTC as its timezone. Otherwise, the same date/time in UTC is returned.
- Returns:
A localized
datetime.datetimein UTC when adatetime.datetimeis given.A localized
datetime.datetimeat midnight in UTC when adatetime.dateis given.A localized
datetime.timein UTC when adatetime.timeis given.
- timezone(tz_id)[source]#
Return a timezone with an ID or
Noneif we can't find it.tz_idmay be a plain Olson name (Europe/Berlin), a Windows timezone name, or a "globally unique" identifier (RFC 5545 Section 3.2.19) such as/freeassociation.sourceforge.net/Europe/Berlin. We try the candidate IDs from_lookup_idsin order, checking the cache before the provider for each one, and cache the first match under the primary ID so the next lookup is fast.A lookup that is resolved by guessing the trailing Olson identifier emits
GloballyUniqueTZIDGuessedon every call, including when the result is served from the cache.