]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add needed strtime functions from nova
authorAngus Salkeld <asalkeld@redhat.com>
Fri, 30 Mar 2012 01:42:01 +0000 (12:42 +1100)
committerAngus Salkeld <asalkeld@redhat.com>
Fri, 30 Mar 2012 01:42:01 +0000 (12:42 +1100)
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/common/utils.py

index 3be57edd5e5d8174a1ed1f47f1da4bd3a76cd8ca..998a90f1cf1a74cb821ec0695a273d1d133fbcc0 100644 (file)
@@ -31,6 +31,7 @@ from eventlet.green import subprocess
 
 from heat.common import exception
 
+PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
 
 def chunkreadable(iter, chunk_size=65536):
     """
@@ -85,6 +86,13 @@ def generate_uuid():
 def gen_uuid():
     return uuid.uuid4()
 
+
+def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
+    """Returns formatted utcnow."""
+    if not at:
+        at = utcnow()
+    return at.strftime(fmt)
+
 def utcnow():
     """Overridable version of utils.utcnow."""
     if utcnow.override_time: