MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / fromutc

Method fromutc

tests/test_code/py/pytz/tzinfo.py:193–201  ·  view source on GitHub ↗

See datetime.tzinfo.fromutc

(self, dt)

Source from the content-addressed store, hash-verified

191 _tzinfos[inf] = self.__class__(inf, _tzinfos)
192
193 def fromutc(self, dt):
194 '''See datetime.tzinfo.fromutc'''
195 if (dt.tzinfo is not None and
196 getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos):
197 raise ValueError('fromutc: dt.tzinfo is not self')
198 dt = dt.replace(tzinfo=None)
199 idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
200 inf = self._transition_info[idx]
201 return (dt + inf[0]).replace(tzinfo=self._tzinfos[inf])
202
203 def normalize(self, dt):
204 '''Correct the timezone information on the given datetime

Callers 1

normalizeMethod · 0.95

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected