MCPcopy Index your code
hub / github.com/RustPython/RustPython / _find_trans

Method _find_trans

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

Source from the content-addressed store, hash-verified

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

Callers 3

utcoffsetMethod · 0.95
dstMethod · 0.95
tznameMethod · 0.95

Calls 3

_get_local_timestampMethod · 0.95
lenFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected