You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both UnixEpochDateTimeOffsetConverter and UnixEpochDateTimeConverter do provided in this document do long unixTime = Convert.ToInt64((value - s_epoch).TotalMilliseconds); Convert.ToInt64 performs Math.Round where in Newtonsoft in DateTimeUtils.cs in method UniversalTicksToJavaScriptTicks it instead divides by 10,000. The code samples should match this and do long unixTime = (value - s_epoch).Ticks / TimeSpan.TicksPerMillisecond; so that the serialization provides the exact same value as Newtonsoft would have.
Type of issue
Typo
Description
Both UnixEpochDateTimeOffsetConverter and UnixEpochDateTimeConverter do provided in this document do
long unixTime = Convert.ToInt64((value - s_epoch).TotalMilliseconds);
Convert.ToInt64 performs Math.Round where in Newtonsoft in DateTimeUtils.cs in method UniversalTicksToJavaScriptTicks it instead divides by 10,000. The code samples should match this and dolong unixTime = (value - s_epoch).Ticks / TimeSpan.TicksPerMillisecond;
so that the serialization provides the exact same value as Newtonsoft would have.Page URL
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-9-0
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md
Document Version Independent Id
9c6a7135-eb75-21a9-1d27-0880459523ca
Article author
@gewarren
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: