From 265020d097f8c35630bdf488a42d3242ed0998b1 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 10 Sep 2025 01:35:25 +1000 Subject: [PATCH] Add support for zoneinfo tzinfo sub-classes. zoneinfo was added to the stdlib in 3.9, and is perhaps the most likely source of tzinfo objects now. Use its 'key' attribute to get a unique timezone identifier, rather than falling back to the tzname, which isn't unique (eg. IST = Ireland, Israel, and India). Fixes #117. --- vobject/icalendar.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vobject/icalendar.py b/vobject/icalendar.py index 5640a77..52ff94b 100644 --- a/vobject/icalendar.py +++ b/vobject/icalendar.py @@ -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)