Fix ImportError when converting a date string to a Datetime object
This commit is contained in:
parent
215622e070
commit
5bfcd61931
1 changed files with 5 additions and 1 deletions
|
|
@ -44,7 +44,11 @@ class ModuleState:
|
||||||
try:
|
try:
|
||||||
return datetime.fromtimestamp(float(self.attributes[name]))
|
return datetime.fromtimestamp(float(self.attributes[name]))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return datetime.fromtimestamp(time.mktime(time.strptime(self.attributes[name][:19], "%Y-%m-%d %H:%M:%S")))
|
while True:
|
||||||
|
try:
|
||||||
|
return datetime.fromtimestamp(time.mktime(time.strptime(self.attributes[name][:19], "%Y-%m-%d %H:%M:%S")))
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue