summaryrefslogtreecommitdiffstats
path: root/openstack/common/utils.py
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-04-04 10:40:42 -0400
committerRussell Bryant <rbryant@redhat.com>2012-04-04 10:40:42 -0400
commit1dde301866bcc5c40fd41aaaf82cf8542c69cb2c (patch)
tree6bfc98a7e3ca46f0f99491a3935e7d2dbd7272b9 /openstack/common/utils.py
parentdcd50714c4f1a207ff53b20475b620de39c0ed4a (diff)
downloadoslo-1dde301866bcc5c40fd41aaaf82cf8542c69cb2c.tar.gz
oslo-1dde301866bcc5c40fd41aaaf82cf8542c69cb2c.tar.xz
oslo-1dde301866bcc5c40fd41aaaf82cf8542c69cb2c.zip
Create openstack.common.timeutils.
Split time related utility functions out of openstack.common.utils into a new module, timeutils. Change-Id: Ic09952cd48e0b4548e410926cc456cbd515a4e56
Diffstat (limited to 'openstack/common/utils.py')
-rw-r--r--openstack/common/utils.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/openstack/common/utils.py b/openstack/common/utils.py
index 0191036..d3d01fa 100644
--- a/openstack/common/utils.py
+++ b/openstack/common/utils.py
@@ -19,7 +19,6 @@
System-level utilities and helper functions.
"""
-import datetime
import logging
import os
import random
@@ -28,12 +27,10 @@ import sys
from eventlet import greenthread
from eventlet.green import subprocess
-import iso8601
from openstack.common import exception
-TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
LOG = logging.getLogger(__name__)
@@ -163,52 +160,6 @@ def import_object(import_str):
return import_class(import_str)
-def isotime(at=None):
- """Stringify time in ISO 8601 format"""
- if not at:
- at = datetime.datetime.utcnow()
- str = at.strftime(TIME_FORMAT)
- tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
- str += ('Z' if tz == 'UTC' else tz)
- return str
-
-
-def parse_isotime(timestr):
- """Parse time from ISO 8601 format"""
- try:
- return iso8601.parse_date(timestr)
- except iso8601.ParseError as e:
- raise ValueError(e.message)
- except TypeError as e:
- raise ValueError(e.message)
-
-
-def normalize_time(timestamp):
- """Normalize time in arbitrary timezone to UTC"""
- offset = timestamp.utcoffset()
- return timestamp.replace(tzinfo=None) - offset if offset else timestamp
-
-
-def utcnow():
- """Overridable version of utils.utcnow."""
- if utcnow.override_time:
- return utcnow.override_time
- return datetime.datetime.utcnow()
-
-
-utcnow.override_time = None
-
-
-def set_time_override(override_time=datetime.datetime.utcnow()):
- """Override utils.utcnow to return a constant time."""
- utcnow.override_time = override_time
-
-
-def clear_time_override():
- """Remove the overridden time."""
- utcnow.override_time = None
-
-
def auth_str_equal(provided, known):
"""Constant-time string comparison.