File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,16 @@ def datetimeJSONEncoder(self, obj):
124
124
return None
125
125
126
126
if isinstance (obj , (datetime .datetime , datetime .date )):
127
- if obj .microsecond != 0 :
127
+ if obj .microsecond :
128
128
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 )) :
130
130
return obj .strftime ('%Y-%m-%d %H:%M:%S' )
131
131
else :
132
132
return obj .strftime ('%Y-%m-%d' )
133
133
elif isinstance (obj [0 ], (datetime .datetime , datetime .date )):
134
134
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
137
137
o .strftime ('%Y-%m-%d' )
138
138
for o in obj ]
139
139
else :
You can’t perform that action at this time.
0 commit comments