Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`. If None, retrieve the preferred timezone from the rcParams dictionary.
(tz=None)
| 206 | |
| 207 | |
| 208 | def _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. |
no outgoing calls
no test coverage detected
searching dependent graphs…