From 8962ca3f84b0444d423fc13ffdc13dd94b435e22 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 30 Mar 2012 12:42:01 +1100 Subject: [PATCH] Add needed strtime functions from nova Signed-off-by: Angus Salkeld --- heat/common/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/heat/common/utils.py b/heat/common/utils.py index 3be57edd..998a90f1 100644 --- a/heat/common/utils.py +++ b/heat/common/utils.py @@ -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: -- 2.45.2