Skip to content

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

@johnthcall

Description

@johnthcall

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


Associated WorkItem - 429407

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions