From 85bed287461036745afe6a4c623e546c52641b1e Mon Sep 17 00:00:00 2001 From: Sirisha Devineni Date: Tue, 9 Oct 2012 17:33:35 +0530 Subject: Added is_newer_than function Added is_newer_than function to compare if the provided time is newer than current time for specified number of seconds Fixes bug 1036343 Change-Id: Ic133b0e7e2337b6b0fdad244ded6a93f8db48379 --- openstack/common/timeutils.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'openstack/common/timeutils.py') diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py index 93b34fc..8600439 100644 --- a/openstack/common/timeutils.py +++ b/openstack/common/timeutils.py @@ -74,6 +74,11 @@ def is_older_than(before, seconds): return utcnow() - before > datetime.timedelta(seconds=seconds) +def is_newer_than(after, seconds): + """Return True if after is newer than seconds.""" + return after - utcnow() > datetime.timedelta(seconds=seconds) + + def utcnow_ts(): """Timestamp version of our utcnow function.""" return calendar.timegm(utcnow().timetuple()) -- cgit