-
Notifications
You must be signed in to change notification settings - Fork 158
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
Avoiding return DateTime.Kind=Unspecified when converting from DateTimeOffset to DateTime (issues 378, 384 and others) #1033
base: release-8.x
Are you sure you want to change the base?
Conversation
…meOffset to DateTime With this modification we would avoid getting a DateTime value (derived from a conversion from a DateTimeOffset value) that has Kind=Unspecified. The problem is mainly evident when passing Dates as parameters of the ODATA $filter option. With this change the conversion will aways return an UTC datetime when it is originated from a DateTimeOffset value.
@microsoft-github-policy-service agree |
Thank you @darkeagle76 for your contribution. The build was triggered and tests are failing after your change. Please check that out |
Is there a reason this hasn't been addressed? This problem breaks any usage of odata with newer Postgres/EFcore with date filtering. Perhaps if there's concern about breaking existing usages, we just need another option on query settings like this that can default to the old way:
|
I don’t know what might have broken due to these changes, but I can definitely say that WITHOUT these changes, it is impossible to work with OData on the new frameworks if time filtering is required. I don't think that's a valid reason to reject this fix.
There is clearly a problem with the expected result, not with the actual one If you're expecting local time here, you can pass it like this:
I believe the issue lies in your tests, not in the proposed fixes. There is a compromise option as suggested above—just pass a function in the settings that will modify the dateTime if needed. At the moment, the only solution to the problem is to abandon the official NuGet package and use the fork from darkeagle76. |
I added a fix so that your tests pass, and I also added a new test that checks for the explicit indication of Kind=UTC. Can we release this fix? At least as a preview version or something like that. We need this fix. |
fixes #378 , fixes #384
With this modification we would avoid getting a DateTime value (derived from a conversion from a DateTimeOffset value) that has Kind=Unspecified. The problem is mainly evident when passing Dates as parameters of the ODATA $filter option. With this change the conversion will aways return an UTC datetime when it is originated from a DateTimeOffset value.
I already provided additional details here: but my original comment remained without answer.
Thanks in advance for considering my request.
D