summaryrefslogtreecommitdiffstats
path: root/openstack/common
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-01-03 11:23:30 -0800
committerDan Smith <danms@us.ibm.com>2013-01-04 06:33:23 -0800
commit09b341db792fa25fe67c560c65f278ce9c70957e (patch)
treeb413da61a70292c7b643304a501c53b83c99031c /openstack/common
parent0ccb03b37a74943430c2e81a3955a94d2c8136c0 (diff)
downloadoslo-09b341db792fa25fe67c560c65f278ce9c70957e.tar.gz
oslo-09b341db792fa25fe67c560c65f278ce9c70957e.tar.xz
oslo-09b341db792fa25fe67c560c65f278ce9c70957e.zip
Make time comparison functions accept strings
This patch makes is_older_than() and is_newer_than() accept timestamps in string format, as returned from strtime(). Change-Id: I1dbf453cc08bd8aaeb4fee2491a1e8aa74f8bee3
Diffstat (limited to 'openstack/common')
-rw-r--r--openstack/common/timeutils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py
index ea69164..e518733 100644
--- a/openstack/common/timeutils.py
+++ b/openstack/common/timeutils.py
@@ -71,11 +71,15 @@ def normalize_time(timestamp):
def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
+ if isinstance(before, str):
+ before = parse_strtime(before).replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds)
def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
+ if isinstance(after, str):
+ after = parse_strtime(after).replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds)