X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=monitor%2Fcommon.py;h=08a6d99d08b19d7e04dec128ddb96716e5591bc5;hp=850d36b592b7c53a4bc54b78c0430463cd7dccbf;hb=0a896f10303078562b737c83fd08dc25f0973c58;hpb=8f41cc57e1e5ea09b376526d738afe0136b7a9e9 diff --git a/monitor/common.py b/monitor/common.py index 850d36b..08a6d99 100644 --- a/monitor/common.py +++ b/monitor/common.py @@ -278,3 +278,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