Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix epoch time calculation if provided datetime has timezone #1287

Merged
merged 1 commit into from
Oct 14, 2016

Conversation

labeneator
Copy link
Contributor

I was hitting the following bug:

2016-10-07 13:26:36,709:ERROR:root:Timestamp subtraction must have the same timezones or no timezones
Traceback (most recent call last):
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/caravel/viz.py", line 328, in get_json
    data = self.json_dumps(payload)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/caravel/viz.py", line 346, in json_dumps
    return json.dumps(obj, default=utils.json_int_dttm_ser, ignore_nan=True)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/simplejson/__init__.py", line 397, in dumps
    **kw).encode(obj)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/simplejson/encoder.py", line 275, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/simplejson/encoder.py", line 357, in iterencode
    return _iterencode(o, 0)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/caravel/utils.py", line 380, in json_int_dttm_ser
    obj = datetime_to_epoch(obj)
  File "/Users/lmwangi/venvs/caravel/lib/python2.7/site-packages/caravel/utils.py", line 367, in datetime_to_epoch
    return (dttm - EPOCH).total_seconds() * 1000
  File "pandas/tslib.pyx", line 1071, in pandas.tslib._Timestamp.__sub__ (pandas/tslib.c:21031)
TypeError: Timestamp subtraction must have the same timezones or no timezones

This PR fixes this issue.

@labeneator labeneator changed the title Fix utc time calculation if provided datetime has timezone Fix epoch time calculation if provided datetime has timezone Oct 7, 2016
@bkyryliuk
Copy link
Member

@labeneator - could you please add a test that reproduces the issue to prevent regressions?

@mistercrunch mistercrunch merged commit 65c744f into apache:master Oct 14, 2016
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants