question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clock drift issue when calling DateUtils#getDateTimeWithMillisPrecision

See original GitHub issue

if using 1623849812.985 works correctly, when using 1623849812.985594 with higher precision in millis, there’s an issue when (seconds * 1000) + millis. I don’t recall RN SDK sending more than millis precision, so I’m not sure if we should fix the Android SDK or the RN SDK.

A simple workaround would be to cut off after 3 digits or make the right calculation

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jennmuengcommented, Jun 24, 2021

Sounds good, just a note that

1591533492.631631 to 2020-06-07T12:38:12.631Z or do we round to the nearest number? eg 2020-06-07T12:38:12.632Z.

In the grooming yesterday I think the team agreed to floor it, so it would be 1591533492.631631 to 2020-06-07T12:38:12.631Z, and 1591533492.999999 to 2020-06-07T12:38:12.999Z

1reaction
marandanetocommented, Jun 24, 2021

ok so figured that out, JS timestamps could have up to 13 decimal places but we don’t need all of that, in Mobile, up to 3 digits is already fine.

Example: 1591533492.631 should be formated to 2020-06-07T12:38:12.631Z 1591533492.63 to 2020-06-07T12:38:12.630Z or just 2020-06-07T12:38:12.63Z 1591533492.6 to 2020-06-07T12:38:12.600Z or just 2020-06-07T12:38:12.6Z 1591533492.631631 to 2020-06-07T12:38:12.631Z or do we round to the nearest number? eg 2020-06-07T12:38:12.632Z.

getDateTimeWithMillisPrecision method right now takes everything after the . assuming it’s only (or max.) 3 digits and sum it up, this causes a clock drift. we need to be sure that the number after the. eg 1591533492.631631631631 is formatted to millis in 3 digits so the calculation won’t be off.

Right now if I pass 1591533492.631631631, it converts to 2020-06-14T20:05:23.631Z instead of 2020-06-07T12:38:12.631Z which is obviously wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clock Drift/Skew code does not handle all skew error scenarios
DateUtils ' isClockSkewError only checks for one kind of error type related to bad clock, but there's actually many possible error types.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found