Fix ImportError when converting a date string to a Datetime object

This commit is contained in:
Némunaire 2012-06-29 01:01:39 +02:00
parent 215622e070
commit 5bfcd61931

View File

@ -44,7 +44,11 @@ class ModuleState:
try:
return datetime.fromtimestamp(float(self.attributes[name]))
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:
return None