summaryrefslogtreecommitdiff
path: root/nova/utils.py
diff options
context:
space:
mode:
authorGábor Antal <antal@inf.u-szeged.hu>2015-11-03 13:10:47 +0100
committerGábor Antal <antal@inf.u-szeged.hu>2015-11-18 17:45:29 +0100
commit630aad025e2d7010d60a2b2257959692e35bbb3f (patch)
tree887f6bebcb8c2731cced383c5d411f79a69f61f8 /nova/utils.py
parent3be51f19ae409a2633251e9bf5c5bdfcda8346a5 (diff)
downloadnova-630aad025e2d7010d60a2b2257959692e35bbb3f.tar.gz
Replaced deprecated timeutils methods
Since oslo 1.6.0 timeutils.isotime() and timeutils.strtime() methods are deprecated. DeprecationWarning: Using function/method 'oslo_utils.timeutils.strtime()' is deprecated in version '1.6' and will be removed in a future version: use either datetime.datetime.isoformat() or datetime.datetime.strftime() instead Change-Id: If69bd8a6bee052556ba8853afef3941bcd1e7b13 Closes-Bug: 1479056 Co-Authored-By: Diana Clarke <diana.joan.clarke@gmail.com>
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index d892bad3a5..1d0e7a6be5 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -1539,3 +1539,21 @@ def delete_cached_file(filename):
if filename in _FILE_CACHE:
del _FILE_CACHE[filename]
+
+
+def isotime(at=None):
+ """Current time as ISO string,
+ as timeutils.isotime() is deprecated
+
+ :returns: Current time in ISO format
+ """
+ if not at:
+ at = timeutils.utcnow()
+ date_string = at.strftime("%Y-%m-%dT%H:%M:%S")
+ tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
+ date_string += ('Z' if tz == 'UTC' else tz)
+ return date_string
+
+
+def strtime(at):
+ return at.strftime("%Y-%m-%dT%H:%M:%S.%f")