MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _get_tzinfo

Function _get_tzinfo

lib/matplotlib/dates.py:208–224  ·  view source on GitHub ↗

Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`. If None, retrieve the preferred timezone from the rcParams dictionary.

(tz=None)

Source from the content-addressed store, hash-verified

206
207
208def _get_tzinfo(tz=None):
209 """
210 Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`.
211 If None, retrieve the preferred timezone from the rcParams dictionary.
212 """
213 tz = mpl._val_or_rc(tz, 'timezone')
214 if tz == 'UTC':
215 return UTC
216 if isinstance(tz, str):
217 tzinfo = dateutil.tz.gettz(tz)
218 if tzinfo is None:
219 raise ValueError(f"{tz} is not a valid timezone as parsed by"
220 " dateutil.tz.gettz.")
221 return tzinfo
222 if isinstance(tz, datetime.tzinfo):
223 return tz
224 raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.")
225
226
227# Time-related constants.

Callers 6

_from_ordinalfFunction · 0.85
num2dateFunction · 0.85
__init__Method · 0.85
set_tzinfoMethod · 0.85
__init__Method · 0.85
set_tzinfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…