icalendar.timezone.tzp module#

class icalendar.timezone.tzp.TZP(provider='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)[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:

str

create_timezone(timezone_component)[source]#

Create a timezone from a timezone component.

This component will not be cached.

fix_rrule_until(rrule, ical_rrule)[source]#

Make sure the until value works.

Return type:

None

localize(dt, tz)[source]#

Localize a datetime to a timezone.

Return type:

datetime

localize_utc(dt)[source]#

Return the datetime in UTC.

If the datetime has no timezone, set UTC as its timezone.

Return type:

datetime

property name: str#

The name of the timezone component used.

timezone(tz_id)[source]#

Return a timezone with an id or None if we cannot find it.

Return type:

Optional[tzinfo]

use(provider)[source]#

Switch to a different timezone provider.

use_default()[source]#

Use the default timezone provider.

use_pytz()[source]#

Use pytz as the timezone provider.

Return type:

None

use_zoneinfo()[source]#

Use zoneinfo as the timezone provider.

Return type:

None

uses_pytz()[source]#

Whether we use pytz at all.

Return type:

bool

uses_zoneinfo()[source]#

Whether we use zoneinfo.

Return type:

bool