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):
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 :
You can’t perform that action at this time.
0 commit comments