File tree 3 files changed +18
-2
lines changed
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 6
6
remove_deprecations ,
7
7
v4_subplots ,
8
8
orca_defaults ,
9
+ timezones ,
9
10
trace_uids ,
10
11
)
11
12
Original file line number Diff line number Diff line change 3
3
import json as _json
4
4
import sys
5
5
import re
6
-
7
6
import pytz
7
+ from _plotly_future_ import _future_flags
8
8
9
9
from _plotly_utils .optional_imports import get_module
10
10
@@ -104,7 +104,9 @@ def default(self, obj):
104
104
self .encode_as_sage ,
105
105
self .encode_as_numpy ,
106
106
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 ),
108
110
self .encode_as_date ,
109
111
self .encode_as_list , # because some values have `tolist` do last.
110
112
self .encode_as_decimal
@@ -170,6 +172,14 @@ def encode_as_numpy(obj):
170
172
else :
171
173
raise NotEncodable
172
174
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
+
173
183
@staticmethod
174
184
def encode_as_datetime (obj ):
175
185
"""Attempt to convert to utc-iso time string using datetime methods."""
You can’t perform that action at this time.
0 commit comments