MCPcopy Index your code
hub / github.com/python/cpython / _find_trans

Method _find_trans

Lib/zoneinfo/_zoneinfo.py:162–187  ·  view source on GitHub ↗
(self, dt)

Source from the content-addressed store, hash-verified

160 return dt
161
162 def _find_trans(self, dt):
163 if dt is None:
164 if self._fixed_offset:
165 return self._tz_after
166 else:
167 return _NO_TTINFO
168
169 ts = self._get_local_timestamp(dt)
170
171 lt = self._trans_local[dt.fold]
172
173 num_trans = len(lt)
174
175 if num_trans and ts < lt[0]:
176 return self._tti_before
177 elif not num_trans or ts > lt[-1]:
178 if isinstance(self._tz_after, _TZStr):
179 return self._tz_after.get_trans_info(ts, dt.year, dt.fold)
180 else:
181 return self._tz_after
182 else:
183 # idx is the transition that occurs after this timestamp, so we
184 # subtract off 1 to get the current ttinfo
185 idx = bisect.bisect_right(lt, ts) - 1
186 assert idx >= 0
187 return self._ttinfos[idx]
188
189 def _get_local_timestamp(self, dt):
190 return (

Callers 3

utcoffsetMethod · 0.95
dstMethod · 0.95
tznameMethod · 0.95

Calls 1

_get_local_timestampMethod · 0.95

Tested by

no test coverage detected