Module: check_mk
Branch: master
Commit: 45041edc9169cbe8620ae180b1e5baa0839d39e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=45041edc9169cb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Oct 25 14:16:34 2015 +0100
New check API function get_relative_date_human_readable
---
modules/check_mk_base.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index cb61385..9986616 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -2198,6 +2198,14 @@ def get_age_human_readable(secs):
return "%d days %d hours" % (days, hours)
return "%d days" % days
+
+def get_relative_date_human_readable(timestamp):
+ now = time.time()
+ if timestamp > now:
+ return "in " + get_age_human_readable(timestamp - now)
+ else:
+ return get_age_human_readable(now - timestamp) + " ago"
+
# Format perc (0 <= perc <= 100 + x) so that precision
# digits are being displayed. This avoids a "0.00%" for
# very small numbers