summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/timeutils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py
index 0f34608..572c829 100644
--- a/openstack/common/timeutils.py
+++ b/openstack/common/timeutils.py
@@ -162,3 +162,16 @@ def delta_seconds(before, after):
except AttributeError:
return ((delta.days * 24 * 3600) + delta.seconds +
float(delta.microseconds) / (10 ** 6))
+
+
+def is_soon(dt, window):
+ """
+ Determines if time is going to happen in the next window seconds.
+
+ :params dt: the time
+ :params window: minimum seconds to remain to consider the time not soon
+
+ :return: True if expiration is within the given duration
+ """
+ soon = (utcnow() + datetime.timedelta(seconds=window))
+ return normalize_time(dt) < soon