Skip to content
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

Sample converters in for Unix Epoch round instead of rountdown #44666

Open
johnthcall opened this issue Feb 3, 2025 · 0 comments
Open

Sample converters in for Unix Epoch round instead of rountdown #44666

johnthcall opened this issue Feb 3, 2025 · 0 comments

Comments

@johnthcall
Copy link

johnthcall commented Feb 3, 2025

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 do long 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

  • ID: 6b74d77c-33e1-d44c-18c6-bd0b612f74de
  • Service: dotnet-fundamentals

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant