X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=monitor%2Fcommon.py;h=5cf815109aa667301e99dfff765615d80272ba63;hp=2eb2bb7e61067d8c73a03b5296b93905cf5c38cd;hb=f4f26439ae2db33f8f9a55e1a3350f6ed4f78278;hpb=dbb6bde37dbd9042af5abb57cc966e5f338776ae 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