More robust ISO date to timestamp conversion

This commit is contained in:
Fabio Manganiello 2020-01-19 15:37:55 +01:00
parent bbb52ba191
commit 42eabcf661

View file

@ -35,6 +35,9 @@ class TravisciBackend(Backend):
@staticmethod @staticmethod
def _convert_iso_date(d): def _convert_iso_date(d):
if not d:
return
if isinstance(d, int) or isinstance(d, float): if isinstance(d, int) or isinstance(d, float):
return d return d
@ -43,7 +46,7 @@ class TravisciBackend(Backend):
d = d[:-1] + '+00:00' d = d[:-1] + '+00:00'
d = datetime.datetime.fromisoformat(d) d = datetime.datetime.fromisoformat(d)
assert isinstance(d, datetime.datetime) assert isinstance(d, datetime.datetime), 'Unexpected datetime type: ' + type(d)
return d.timestamp() return d.timestamp()
def __enter__(self): def __enter__(self):