Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Parameter Issue #57

Open
brandon71 opened this issue Feb 1, 2022 · 1 comment
Open

Date Parameter Issue #57

brandon71 opened this issue Feb 1, 2022 · 1 comment

Comments

@brandon71
Copy link

We are testing the API and came across an issue with dates.
We were testing both GetCustomers and GetOrders with the CreatedAtMin parameter and are seeing the same issue with both.

When we pass a date in the format specified, the property is not being parsed and is set to null. If we send the date with out the time (2008-12-31) the date is parsed with the time set to 12:00am.
///


/// Show orders created after date (format: 2008-12-31 03:00)
///

[JsonProperty("created_at_min")]
public DateTime? CreatedAtMin { get; set; }

i.e
https://localhost:44369/api/orders?status=pending&CreatedAtMin=2008-12-31 03:00

If we remove the model binder attribute from the OrdersParametersModel the datetime (2008-12-31 03:00) is parsed as expected.
[ModelBinder(typeof(ParametersModelBinder))]

It appears the model binder attribute is causing issues with datetimes.

@brandon71
Copy link
Author

Digging into the code we found that the date format in the documentation is not one of the valid formats.
Putting the date into the format 2008-12-31T03:00 allows the CreatedAtMin date value to function as expected.

Valid Date formats are identified in the APITypeConverter Class are:
var formats = new[]
{
"yyyy", "yyyy-MM", "yyyy-MM-dd", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss",
"yyyy-MM-ddTHH:mm:sszzz", "yyyy-MM-ddTHH:mm:ss.FFFFFFFK"
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant