Skip to content

Commit

Permalink
Fixes apache#721 - [mktime out of range]
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jul 13, 2016
1 parent 09c95fb commit 6c6bee9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion caravel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from sqlalchemy.types import TypeDecorator, TEXT
from pydruid.utils.having import Having

EPOCH = datetime(1970, 1, 1)


class CaravelException(Exception):
pass
Expand Down Expand Up @@ -309,7 +311,7 @@ def json_int_dttm_ser(obj):
if val is not None:
return val
if isinstance(obj, datetime):
obj = int(time.mktime(obj.timetuple())) * 1000
obj = (obj - EPOCH).total_seconds() * 1000
else:
raise TypeError(
"Unserializable object {} of type {}".format(obj, type(obj))
Expand Down

0 comments on commit 6c6bee9

Please sign in to comment.