make more protable across python3 minor versions
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def get_date() -> dict:
|
def get_date() -> dict:
|
||||||
@@ -25,7 +26,10 @@ def to_date_str(_date: dict):
|
|||||||
|
|
||||||
|
|
||||||
def create_timestamp():
|
def create_timestamp():
|
||||||
|
if sys.version_info.major > 2 and sys.version_info.minor > 8:
|
||||||
now = datetime.datetime.now(datetime.UTC)
|
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') + ('.%03dZ' % (now.microsecond / 1000))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user