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

Skip to content

Commit 3f1fe9e

Browse files
committed
datetime any :lipstick;
1 parent 8709eb4 commit 3f1fe9e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plotly/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,16 @@ def datetimeJSONEncoder(self, obj):
124124
return None
125125

126126
if isinstance(obj, (datetime.datetime, datetime.date)):
127-
if obj.microsecond != 0:
127+
if obj.microsecond:
128128
return obj.strftime('%Y-%m-%d %H:%M:%S.%f')
129-
elif obj.second != 0 or obj.minute != 0 or obj.hour != 0:
129+
elif any((obj.second, obj.minute, obj.hour)):
130130
return obj.strftime('%Y-%m-%d %H:%M:%S')
131131
else:
132132
return obj.strftime('%Y-%m-%d')
133133
elif isinstance(obj[0], (datetime.datetime, datetime.date)):
134134
return [o.strftime(
135-
'%Y-%m-%d %H:%M:%S.%f') if o.microsecond != 0 else
136-
o.strftime('%Y-%m-%d %H:%M:%S') if o.second != 0 or o.minute != 0 or o.hour != 0 else
135+
'%Y-%m-%d %H:%M:%S.%f') if o.microsecond else
136+
o.strftime('%Y-%m-%d %H:%M:%S') if any((o.second, o.minute, o.hour)) else
137137
o.strftime('%Y-%m-%d')
138138
for o in obj]
139139
else:

0 commit comments

Comments
 (0)