summaryrefslogtreecommitdiffstats
path: root/openstack/common/timeutils.py
diff options
context:
space:
mode:
authorSirisha Devineni <sirisha_devineni@persistent.co.in>2012-10-09 17:33:35 +0530
committerSirisha Devineni <sirisha_devineni@persistent.co.in>2012-10-09 17:53:23 +0530
commit85bed287461036745afe6a4c623e546c52641b1e (patch)
tree6527b03a83b00cd83eb1effa8691cea600f21383 /openstack/common/timeutils.py
parent355ca27471218012a7604b751b1ffbbd2d001f05 (diff)
downloadoslo-85bed287461036745afe6a4c623e546c52641b1e.tar.gz
oslo-85bed287461036745afe6a4c623e546c52641b1e.tar.xz
oslo-85bed287461036745afe6a4c623e546c52641b1e.zip
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
Diffstat (limited to 'openstack/common/timeutils.py')
-rw-r--r--openstack/common/timeutils.py5
1 files changed, 5 insertions, 0 deletions
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())