From 6c6bee95007ac095a191ee892d421bbef5c1f8b9 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 13 Jul 2016 11:11:30 -0400 Subject: [PATCH] Fixes #721 - [mktime out of range] --- caravel/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/caravel/utils.py b/caravel/utils.py index 97615aab9c70..26e05b77e94d 100644 --- a/caravel/utils.py +++ b/caravel/utils.py @@ -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 @@ -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))