misc: add support for serializing times to json (#76021)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6d11417ae3
commit
f7c49be99d
|
@ -2411,6 +2411,7 @@ def test_webservice_with_complex_data(http_requests, pub):
|
|||
'none': '{{ form_var_none }}',
|
||||
'bool': '{{ form_var_bool_raw }}',
|
||||
'attachment': '{{ form_attachments_testfile }}',
|
||||
'time': '{{ "13:12"|time }}',
|
||||
}
|
||||
pub.substitutions.feed(formdata)
|
||||
with get_publisher().complex_data():
|
||||
|
@ -2442,6 +2443,7 @@ def test_webservice_with_complex_data(http_requests, pub):
|
|||
'content_type': 'application/octet-stream',
|
||||
'content': base64.b64encode(attachment_content).decode(),
|
||||
},
|
||||
'time': '13:12:00',
|
||||
}
|
||||
|
||||
# check an empty boolean field is sent as False
|
||||
|
|
|
@ -616,6 +616,9 @@ class JSONEncoder(json.JSONEncoder):
|
|||
if isinstance(o, datetime.date):
|
||||
return o.strftime('%Y-%m-%d')
|
||||
|
||||
if isinstance(o, datetime.time):
|
||||
return o.strftime('%H:%M:%S')
|
||||
|
||||
if isinstance(o, decimal.Decimal):
|
||||
return localize(o)
|
||||
|
||||
|
|
Loading…
Reference in New Issue