From 65c744f2424d111e950b385630bd8a13b3fa003e Mon Sep 17 00:00:00 2001 From: ComputeThis Date: Fri, 14 Oct 2016 07:03:20 +0300 Subject: [PATCH] Fix utc time calculation if provided datetime has tz info (#1287) --- caravel/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/caravel/utils.py b/caravel/utils.py index f3f196730..968b9e9cf 100644 --- a/caravel/utils.py +++ b/caravel/utils.py @@ -10,6 +10,7 @@ import decimal import functools import json import logging +import pytz import numpy import signal import uuid @@ -368,6 +369,9 @@ def json_iso_dttm_ser(obj): def datetime_to_epoch(dttm): + if dttm.tzinfo: + epoch_with_tz = pytz.utc.localize(EPOCH) + return (dttm - epoch_with_tz).total_seconds() * 1000 return (dttm - EPOCH).total_seconds() * 1000