X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fcommon.py;h=5cf815109aa667301e99dfff765615d80272ba63;hb=dd301eafa4f964ec3dfc28bda85c3576ac9ee634;hp=2eb2bb7e61067d8c73a03b5296b93905cf5c38cd;hpb=7739f7d2f05d32b35ddeef39b864e9c1524fa6d4;p=monitor.git diff --git a/monitor/common.py b/monitor/common.py index 2eb2bb7..5cf8151 100644 --- a/monitor/common.py +++ b/monitor/common.py @@ -282,3 +282,14 @@ def found_within(recent_actions, action_type, within): print "%s NOT found_within %s in recent_actions" % (action_type, timedelta(within) ) return False + +class Time: + @classmethod + def dt_to_ts(cls, dt): + t = time.mktime(dt.timetuple()) + return t + + @classmethod + def ts_to_dt(cls, ts): + d = datetime.fromtimestamp(ts) + return d