icalendar.timezone.tzid module#

This module identifies timezones.

Normally, timezones have ids. This is a way to access the ids if you have a datetime.tzinfo object.

icalendar.timezone.tzid.is_utc(t)[source]#

Whether this date is in UTC.

Return type:

bool

icalendar.timezone.tzid.tzid_from_dt(dt)[source]#

Retrieve the timezone id from the datetime object.

Return type:

Optional[str]

icalendar.timezone.tzid.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.

Return type:

Optional[str]

icalendar.timezone.tzid.tzids_from_tzinfo(tzinfo)[source]#

Get several timezone ids if we can identify the timezone.

Return type:

tuple[str]

>>> 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')