DateTimeOffset gets converted to DateTime with DateTimeKind.Unspecified.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 864
- Forks
- 467
- PR merge metrics
- No merged PRs in 30d
Description
DateTimeOffset gets converted to DateTime with DateTimeKind.Unspecified. This makes it hard to know what the time actually is.
Assemblies affected
System.Web.OData, Version=5.9.0.0
Reproduce steps
Define an entity type based on a .NET class with a property of type DateTime using ODataConventionModelBuilder.
Create a simple controller for it with a Post method.
Post and entity to it with the date specified including time zone, say, "2016-09-03T09:36:35.7788542Z"
Look at the value of the property. It has DateTimeKind.Unspecified.
Expected result
Should be Utc or Local.
Actual result
DateTimeKind is Unspecified
Additional details
System.Web.OData.Formatter.EdmPrimitiveHelpers.ConvertPrimitiveValue already offset to local time zone when converting DateTimeOffset to DateTime. Yet, because dateTimeOffsetValue.DateTime is used instead of either dateTimeOffsetValue.LocalDateTime or dateTimeOffsetValue.UtcDateTime the DateTime has the DateTimeKind.Unkown kind.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at System.Web.OData.Formatter.EdmPrimitiveHelpers.ConvertPrimitiveValue and inspect the DateTimeOffset-to-DateTime conversion path described in the report. Verify the resulting DateTime preserves an appropriate Utc or Local kind rather than Unspecified, then run the existing formatter tests covering primitive conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100