Skip to content

Stop auto-converting timezones to UTC and stripping timezone info #1581

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

Merged
merged 3 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _plotly_future_/timezones.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import
from _plotly_future_ import _future_flags, _assert_plotly_not_imported

_assert_plotly_not_imported()
_future_flags.add('timezones')
1 change: 1 addition & 0 deletions _plotly_future_/v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
remove_deprecations,
v4_subplots,
orca_defaults,
timezones,
trace_uids,
)

14 changes: 12 additions & 2 deletions _plotly_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import json as _json
import sys
import re

import pytz
from _plotly_future_ import _future_flags

from _plotly_utils.optional_imports import get_module

Expand Down Expand Up @@ -104,7 +104,9 @@ def default(self, obj):
self.encode_as_sage,
self.encode_as_numpy,
self.encode_as_pandas,
self.encode_as_datetime,
(self.encode_as_datetime_v4
if 'timezones' in _future_flags
else self.encode_as_datetime),
self.encode_as_date,
self.encode_as_list, # because some values have `tolist` do last.
self.encode_as_decimal
Expand Down Expand Up @@ -170,6 +172,14 @@ def encode_as_numpy(obj):
else:
raise NotEncodable

@staticmethod
def encode_as_datetime_v4(obj):
"""Convert datetime objects to iso-format strings"""
try:
return obj.isoformat()
except AttributeError:
raise NotEncodable

@staticmethod
def encode_as_datetime(obj):
"""Attempt to convert to utc-iso time string using datetime methods."""
Expand Down