omit microseconds from file name

This commit is contained in:
2024-10-20 19:45:09 +02:00
parent 40ad69eccd
commit 8691032665
2 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -25,12 +25,15 @@ def to_date_str(_date: dict):
return f"{_date['year']:04d}-{_date['month']:02d}-{_date['day']:02d}"
def create_timestamp():
def create_timestamp(with_ms=True):
if sys.version_info.major > 2 and sys.version_info.minor > 9:
now = datetime.datetime.now(datetime.UTC)
else:
now = datetime.datetime.utcnow()
res = now.strftime('%Y-%m-%dT%H:%M:%S') + ('.%03dZ' % (now.microsecond / 1000))
res = now.strftime('%Y-%m-%dT%H:%M:%S')
if with_ms:
res += ('.%03dZ' % (now.microsecond / 1000))
return res