Add docstring to supybot.utils.time.iana_timezone

This commit is contained in:
Valentin Lorentz 2021-11-08 23:20:28 +01:00
parent 12c526bc1c
commit feaa02ab6d
1 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,14 @@ class UnknownTimeZone(TimezoneException):
pass
def iana_timezone(name):
"""Returns a :class:datetime.tzinfo object, given an IANA timezone name,
eg. ``"Europe/Paris"``.
This uses :class:``zoneinfo.ZoneInfo`` if available,
:func:``pytz.timezone`` otherwise.
May raise instances of :exc:`TimezoneException`.
"""
if not _IANA_TZ_RE.match(name):
raise UnknownTimeZone(name)