Skip to content

Commit 2a22f03

Browse files
committed
save date in json, fixes (#651)
1 parent 5775bac commit 2a22f03

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

supervised/utils/jsonencoder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import numpy as np
3-
3+
from datetime import date
44

55
class MLJSONEncoder(json.JSONEncoder):
66
def default(self, o):
@@ -25,5 +25,7 @@ def default(self, o):
2525
return float(o)
2626
elif isinstance(o, np.ndarray):
2727
return o.tolist()
28+
elif isinstance(obj, date):
29+
return obj.strftime("%Y-%m-%d")
2830

29-
return super().default(o)
31+
return super(MLJSONEncoder, self).default(o)

0 commit comments

Comments
 (0)