From 56f3839fd5427420102d4676b0b5326db6bca184 Mon Sep 17 00:00:00 2001 From: Thomas Pollet Date: Tue, 12 Dec 2023 08:35:34 +0100 Subject: [PATCH] add timedelta encoding --- safrs/json_encoder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/safrs/json_encoder.py b/safrs/json_encoder.py index e0a823a..ec8f4df 100755 --- a/safrs/json_encoder.py +++ b/safrs/json_encoder.py @@ -72,6 +72,8 @@ def default(self, obj, **kwargs): if isinstance(obj, Included): result = obj.encode() return result + if isinstance(obj, datetime.timedelta): + return str(obj) if isinstance(obj, SAFRSBase): result = obj._s_jsonapi_encode() return result @@ -157,4 +159,4 @@ class SAFRSJSONEncoder(_SAFRSJSONEncoder, json.JSONEncoder): """ Common JSON encoding """ - pass \ No newline at end of file + pass