MCPcopy Index your code
hub / github.com/coleifer/huey / normalize_time

Function normalize_time

huey/utils.py:104–125  ·  view source on GitHub ↗
(eta=None, delay=None, utc=True)

Source from the content-addressed store, hash-verified

102
103
104def normalize_time(eta=None, delay=None, utc=True):
105 if (delay is None) == (eta is None):
106 raise ValueError('Specify either an eta (datetime) or delay (seconds)')
107 elif delay is not None:
108 method = (utc and utcnow or
109 datetime.datetime.now)
110 if not isinstance(delay, datetime.timedelta):
111 delay = datetime.timedelta(seconds=delay)
112 return method() + delay
113 elif not isinstance(eta, datetime.datetime):
114 raise ValueError('eta must be a datetime instance')
115 else:
116 has_tz = not is_naive(eta)
117 if utc:
118 if not has_tz:
119 eta = local_to_utc(eta)
120 else:
121 eta = aware_to_utc(eta)
122 elif has_tz:
123 # Convert TZ-aware into naive localtime.
124 eta = make_naive(eta)
125 return eta
126
127
128def encode(s):

Callers 9

_executeMethod · 0.90
revoke_allMethod · 0.90
revokeMethod · 0.90
scheduleMethod · 0.90
sMethod · 0.90
rescheduleMethod · 0.90
test_normalize_timeMethod · 0.90
test_zero_delayMethod · 0.90
normalize_expire_timeFunction · 0.85

Calls 4

is_naiveFunction · 0.85
local_to_utcFunction · 0.85
aware_to_utcFunction · 0.85
make_naiveFunction · 0.85

Tested by 2

test_normalize_timeMethod · 0.72
test_zero_delayMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…