diff --git a/vobject/icalendar.py b/vobject/icalendar.py index 325bae7..52ff94b 100644 --- a/vobject/icalendar.py +++ b/vobject/icalendar.py @@ -80,7 +80,7 @@ def getTzid(tzid, smart=True): tz = timezone(tzid) registerTzid(toUnicode(tzid), tz) except UnknownTimeZoneError as e: - logging.error(e) + logging.error("Unknown Timezone: %r", e.args[0]) except ImportError as e: logging.error(e) return tz @@ -335,6 +335,10 @@ def pickTzid(tzinfo, allowUTC=False): if tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)): return None + # Try a zoneinfo (CPython 3.9+) first. + if hasattr(tzinfo, 'key'): + return toUnicode(tzinfo.key) + # Try pytz tzid key if hasattr(tzinfo, 'tzid'): return toUnicode(tzinfo.tzid)