AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Use DateTime in ISO format in request and response

Open Reena-Patel opened this issue 4 years ago • 6 comments
trafficstars

Short summary (3-5 sentences) describing the issue.

We want to use the ISO date-time format yyyy-MM-dd'T'HH:mm:ssZ for the Odata API request and response.

Which assemblies and versions are known to be affected e.g. OData WebApi lib 6.1.0

Microsoft.AspNetCore.OData(8.0.2) linq2db.EntityFrameworkCore(5.5.0)

What is actually happening.

{ "id": 11123, "customer_id": 3, "customer_name": "Test By Vishal Thoriya", "receipted_at": "2018-11-15T12:00:00+05:30", "payment_method_type": "EFT", "reference": "erytruy", "amount": 113.0000, "payment_processing_type": "manual", "transaction_id": "erytruy", "status": "Completed", "customer_type": "buyer" },

Currently, it is giving results in above datetime format "2018-11-15T12:00:00+05:30", but we want in "2021-04-13T14:15:22Z"

Reena-Patel avatar Sep 15 '21 11:09 Reena-Patel

@Reena-Patel Can you use the TimeZoneInfo configuration on ODataOptions?

xuzhg avatar Sep 30 '21 17:09 xuzhg

@Reena-Patel Was you issue resolved?

KenitoInc avatar Apr 14 '22 08:04 KenitoInc

@KenitoInc No

Reena-Patel avatar Apr 14 '22 11:04 Reena-Patel

Did you try @xuzhg's suggestion?

KenitoInc avatar Apr 14 '22 12:04 KenitoInc

Is there any chance to fix this issue?

It would be nice if the AddODataNewtonsoftJson method is allow to pass a parameter of JsonSerializerSettings type

ArdynVex avatar Apr 19 '22 15:04 ArdynVex

Is there any chance to fix this issue?

There is nothing to "fix" though, unless you mean the suggestion above doesn't work for you. Date formatting is already configurable.

It would be nice if the AddODataNewtonsoftJson method is allow to pass a parameter of JsonSerializerSettings type

I'm not sure that method does what you think it does... OData has it's own Json serialization logic that it uses for actual OData-formatted payloads. This method just adds a few converters to "tell" Newtonsoft how to serialize a few of its specific types so they can work outside of OData contexts, so passing JsonSerializerSettings on that method would make very little sense I think.

julealgon avatar Apr 19 '22 15:04 julealgon