File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1+ from __future__ import absolute_import
2+ from _plotly_future_ import _future_flags , _assert_plotly_not_imported
3+
4+ _assert_plotly_not_imported ()
5+ _future_flags .add ('timezones' )
Original file line number Diff line number Diff line change 66 remove_deprecations ,
77 v4_subplots ,
88 orca_defaults ,
9+ timezones ,
910 trace_uids ,
1011)
1112
Original file line number Diff line number Diff line change 33import json as _json
44import sys
55import re
6-
76import pytz
7+ from _plotly_future_ import _future_flags
88
99from _plotly_utils .optional_imports import get_module
1010
@@ -104,7 +104,9 @@ def default(self, obj):
104104 self .encode_as_sage ,
105105 self .encode_as_numpy ,
106106 self .encode_as_pandas ,
107- self .encode_as_datetime ,
107+ (self .encode_as_datetime_v4
108+ if 'timezones' in _future_flags
109+ else self .encode_as_datetime ),
108110 self .encode_as_date ,
109111 self .encode_as_list , # because some values have `tolist` do last.
110112 self .encode_as_decimal
@@ -170,6 +172,14 @@ def encode_as_numpy(obj):
170172 else :
171173 raise NotEncodable
172174
175+ @staticmethod
176+ def encode_as_datetime_v4 (obj ):
177+ """Convert datetime objects to iso-format strings"""
178+ try :
179+ return obj .isoformat ()
180+ except AttributeError :
181+ raise NotEncodable
182+
173183 @staticmethod
174184 def encode_as_datetime (obj ):
175185 """Attempt to convert to utc-iso time string using datetime methods."""
You can’t perform that action at this time.
0 commit comments