From: Angus Salkeld Date: Fri, 30 Mar 2012 01:42:01 +0000 (+1100) Subject: Add needed strtime functions from nova X-Git-Tag: 2014.1~2088^2~9 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8962ca3f84b0444d423fc13ffdc13dd94b435e22;p=openstack-build%2Fheat-build.git Add needed strtime functions from nova Signed-off-by: Angus Salkeld --- 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: