StevenRasmussen / EFCore.SqlServer.NodaTime

NodaTime support for EF Core
MIT License
109 stars 18 forks source link

Problem with InstantConverter .ToUniversalTime #1

Closed Franklin89 closed 4 years ago

Franklin89 commented 4 years ago

I am using an Instant for my Created and Modified date and times. If I save the object to the SQL Server the UTC Time is saved as DateTime. Which is all correct. But when I load the object and check the Instant it is at the wrong UTC Time. I suppose this is because of the following line.

https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime/blob/51a68a34c9335b874804c9b910096b494d1a9695/src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime/Storage/InstantValueConverter.cs#L24

If EF Core Maps to a DateTime the Kind will most likely be Unspecified. Calling ToUniversalTime will change the offset depending on the machines timezone. So I think there is no need for the ToUniversalTime method call.

Franklin89 commented 4 years ago

@StevenRasmussen Will you publish a new NuGet package? :-)

StevenRasmussen commented 4 years ago

@Franklin89 - Definitely! I'm trying to wrap up some unit tests around DateDiff and DateDiffBig functionality that I've implemented. Once that's complete I'll publish a new package.

Franklin89 commented 4 years ago

Perfect 👍 awesome work you have done 👍

StevenRasmussen commented 4 years ago

Thanks! Just published v1.3.0 which includes your fix.