Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b517175

Browse files
committed
dates don't have times
1 parent d239f13 commit b517175

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

plotly/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,16 @@ def datetimeJSONEncoder(self, obj):
123123
if _pandas_imported and obj is pandas.NaT:
124124
return None
125125

126-
if isinstance(obj, (datetime.datetime, datetime.date)):
126+
127+
if isinstance(obj, datetime.datetime):
127128
if obj.microsecond:
128129
return obj.strftime('%Y-%m-%d %H:%M:%S.%f')
129130
elif any((obj.second, obj.minute, obj.hour)):
130131
return obj.strftime('%Y-%m-%d %H:%M:%S')
131132
else:
132133
return obj.strftime('%Y-%m-%d')
134+
elif isinstance(obj, datetime.date):
135+
return obj.strftime('%Y-%m-%d')
133136
else:
134137
raise NotEncodable
135138

0 commit comments

Comments
 (0)