Module: check_mk
Branch: master
Commit: 70556b99a66865cf983775282143d4c8a1591db0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=70556b99a66865…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 29 16:29:45 2016 +0200
cmk-lib: new functions render.timespan and render.time_since
---
lib/render.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/render.py b/lib/render.py
index 0ad5c70..326e096 100644
--- a/lib/render.py
+++ b/lib/render.py
@@ -54,6 +54,17 @@ def time_of_day(timestamp):
return time.strftime("%H:%M:%S", time.localtime(timestamp))
+def timespan(seconds):
+ hours, secs = divmod(seconds, 3600)
+ mins, secs = divmod(secs, 60)
+ return "%d:%02d:%02d" % (hours, mins, secs)
+
+
+def time_since(timestamp):
+ return timespan(time.time() - timestamp)
+
+
+
# Precise size of a file - separated decimal separator
# 1234 -> "1234"
# 12345 => "12,345"