MCPcopy Create free account
hub / github.com/python/cpython / _get_trans_info

Method _get_trans_info

Lib/zoneinfo/_zoneinfo.py:465–487  ·  view source on GitHub ↗

Get the information about the current transition - tti

(self, ts, year, fold)

Source from the content-addressed store, hash-verified

463 return start, end
464
465 def _get_trans_info(self, ts, year, fold):
466 """Get the information about the current transition - tti"""
467 start, end = self.transitions(year)
468
469 # With fold = 0, the period (denominated in local time) with the
470 # smaller offset starts at the end of the gap and ends at the end of
471 # the fold; with fold = 1, it runs from the start of the gap to the
472 # beginning of the fold.
473 #
474 # So in order to determine the DST boundaries we need to know both
475 # the fold and whether DST is positive or negative (rare), and it
476 # turns out that this boils down to fold XOR is_positive.
477 if fold == (self.dst_diff >= 0):
478 end -= self.dst_diff
479 else:
480 start += self.dst_diff
481
482 if start < end:
483 isdst = start <= ts < end
484 else:
485 isdst = not (end <= ts < start)
486
487 return self.dst if isdst else self.std
488
489 def _get_trans_info_fromutc(self, ts, year):
490 start, end = self.transitions(year)

Callers

nothing calls this directly

Calls 1

transitionsMethod · 0.95

Tested by

no test coverage detected