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

Function _probe_instants

tests/test_tzpath_data.py:46–67  ·  view source on GitHub ↗

Instants (in UTC) around the interesting parts of a zone.

(zone)

Source from the content-addressed store, hash-verified

44
45
46def _probe_instants(zone):
47 """Instants (in UTC) around the interesting parts of a zone."""
48 instants = list(FIXED_INSTANTS)
49
50 # Explicit transitions: the first few, and the last ones, which are
51 # followed by the TZ string.
52 transitions = list(zone._trans_utc)
53 for ts in transitions[:3] + transitions[-10:]:
54 for delta in (-1, 0, 1):
55 instants.append(_from_timestamp(ts + delta))
56
57 # Transitions generated from the TZ string in the footer.
58 if isinstance(zone._tz_after, _TZStr):
59 std_offset = zone._tz_after.std.utcoff
60 std_offset = std_offset.days * 86400 + std_offset.seconds
61 for year in (2040, 2100):
62 for local_ts in zone._tz_after.transitions(year):
63 utc_ts = local_ts - std_offset
64 for delta in (-7201, -3601, -1, 0, 1, 3599, 7199):
65 instants.append(_from_timestamp(utc_ts + delta))
66
67 return [instant for instant in instants if instant is not None]
68
69
70def _keys():

Callers 3

test_utc_round_tripFunction · 0.85
test_matches_zoneinfoFunction · 0.85

Calls 3

_from_timestampFunction · 0.85
appendMethod · 0.80
transitionsMethod · 0.45

Tested by

no test coverage detected