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

Function zt_as_tuple

tests/test_tzfile.py:138–151  ·  view source on GitHub ↗
(zt)

Source from the content-addressed store, hash-verified

136 ranges = [v1_range, v2_range]
137
138 def zt_as_tuple(zt):
139 # zt may be a tuple (timestamp, offset_before, offset_after) or
140 # a ZoneTransition object -- this is to allow the timestamp to be
141 # values that are outside the valid range for datetimes but still
142 # valid 64-bit timestamps.
143 if isinstance(zt, tuple):
144 return zt
145
146 if zt.transition:
147 trans_time = int(datetime.timestamp(zt.transition_utc))
148 else:
149 trans_time = None
150
151 return (trans_time, zt.offset_before, zt.offset_after)
152
153 transitions = sorted(map(zt_as_tuple, transitions), key=lambda x: x[0])
154

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected