New file_date_time_stamp function
Returns the current date in yymmdd.HHMMSS format.
This can be used to create filenames such as file1.181001.171716.status.
Change-Id: Ibafc40ca016e4ab6483e8e15dd615eaf4c41fd43
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_misc.py b/lib/gen_misc.py
index f66caff..f236320 100755
--- a/lib/gen_misc.py
+++ b/lib/gen_misc.py
@@ -10,6 +10,7 @@
import os
import collections
import json
+import time
try:
import ConfigParser
except ImportError:
@@ -556,3 +557,14 @@
return json.loads(buffer, object_pairs_hook=DotDict)
else:
return json.loads(buffer, object_pairs_hook=collections.OrderedDict)
+
+
+def file_date_time_stamp():
+ r"""
+ Return a date/time stamp in the following format: yymmdd.HHMMSS
+
+ This value is suitable for including in file names. Example
+ file1.181001.171716.status
+ """
+
+ return time.strftime("%y%m%d.%H%M%S", time.localtime(time.time()))