MCPcopy
hub / github.com/YelpArchive/elastalert / pretty_ts

Function pretty_ts

elastalert/util.py:196–205  ·  view source on GitHub ↗

Pretty-format the given timestamp (to be printed or logged hereafter). If tz, the timestamp will be converted to local time. Format: YYYY-MM-DD HH:MM TZ

(timestamp, tz=True)

Source from the content-addressed store, hash-verified

194
195
196def pretty_ts(timestamp, tz=True):
197 """Pretty-format the given timestamp (to be printed or logged hereafter).
198 If tz, the timestamp will be converted to local time.
199 Format: YYYY-MM-DD HH:MM TZ"""
200 dt = timestamp
201 if not isinstance(timestamp, datetime.datetime):
202 dt = ts_to_dt(timestamp)
203 if tz:
204 dt = dt.astimezone(dateutil.tz.tzlocal())
205 return dt.strftime('%Y-%m-%d %H:%M %Z')
206
207
208def ts_add(ts, td):

Callers 15

get_hitsMethod · 0.85
get_hits_countMethod · 0.85
get_hits_termsMethod · 0.85
handle_pending_alertsMethod · 0.85
handle_config_changeMethod · 0.85
handle_rule_executionMethod · 0.85
reset_rule_scheduleMethod · 0.85
processMethod · 0.85
get_match_strMethod · 0.85
get_match_strMethod · 0.85
get_match_strMethod · 0.85
get_match_strMethod · 0.85

Calls 1

ts_to_dtFunction · 0.85

Tested by

no test coverage detected