-
-
Notifications
You must be signed in to change notification settings - Fork 158
DateTimes lose their kind on persistence, becoming ambiguous #873
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
Comments
Thanks for reporting this. I vaguely recall seeing something similar in the past. There are basically two parts that play a role in this: Newtonsoft.JSON serialization settings and database date/time storage (which varies per provider and column type). In the case of serialization, I think the best we can potentially do here (if it helps) is change our defaults in In the case of database providers, picking a different column type may do the trick. Or perhaps switching to To better understand what is going wrong in your case, we need some more info, like what database provider you are using, the column type etc. It would help if you can isolate the place where |
Dug further, and the loss of In retrospect, this makes sense, since Microsoft's official guidance is to use
I tested using @bart-degreed Feel free to close this issue, since a workaround exists and is probably a best practice anyways. Workaround Test NotesI tested on SHA 638a603 (latest master commit as of this comment) with SQL Server as the database provider. With these two resources:
In SQL Server, the DateTime test cases
DateTimeOffset test cases
|
Thanks for investigating and sharing your results. I'm closing this issue, but its nice to have it for future reference. |
Uh oh!
There was an error while loading. Please reload this page.
Description
According to the JSON:API recommendations, datetimes should use an unambiguous ISO 8601 format. However, it appears that
DateTime.Kind
is lost on persistence, causing subsequent operations to return timestamps withDateTimeKind.Unspecified
, which is ambiguous:For example, if you post a new entity with a datetime like
2020-11-04T01:30:53.113Z
(which is unambiguous), the response datetime comes back like2020-11-03T20:30:53.113
(which is ambiguous, especially if clients operate in a different timezone than the server).Environment
The text was updated successfully, but these errors were encountered: