MCPcopy Create free account
hub / github.com/dateutil/dateutil / _build_tzinfo

Method _build_tzinfo

src/dateutil/parser/_parser.py:1159–1175  ·  view source on GitHub ↗
(self, tzinfos, tzname, tzoffset)

Source from the content-addressed store, hash-verified

1157 # subclassing.
1158
1159 def _build_tzinfo(self, tzinfos, tzname, tzoffset):
1160 if callable(tzinfos):
1161 tzdata = tzinfos(tzname, tzoffset)
1162 else:
1163 tzdata = tzinfos.get(tzname)
1164 # handle case where tzinfo is paased an options that returns None
1165 # eg tzinfos = {'BRST' : None}
1166 if isinstance(tzdata, datetime.tzinfo) or tzdata is None:
1167 tzinfo = tzdata
1168 elif isinstance(tzdata, text_type):
1169 tzinfo = tz.tzstr(tzdata)
1170 elif isinstance(tzdata, integer_types):
1171 tzinfo = tz.tzoffset(tzname, tzdata)
1172 else:
1173 raise TypeError("Offset must be tzinfo subclass, tz string, "
1174 "or int offset.")
1175 return tzinfo
1176
1177 def _build_tzaware(self, naive, res, tzinfos):
1178 if (callable(tzinfos) or (tzinfos and res.tzname in tzinfos)):

Callers 1

_build_tzawareMethod · 0.95

Calls 2

tzoffsetMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected