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

Fix FBA timestamps that sometimes are in seconds instead of milliseconds #665

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

norkans7
Copy link
Contributor

@norkans7 norkans7 commented Dec 4, 2023

No description provided.

@norkans7 norkans7 requested a review from rowanseymour December 4, 2023 12:25
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (80e3f68) 74.23% compared to head (e13b8c5) 74.24%.

❗ Current head e13b8c5 differs from pull request most recent head 2041140. Consider uploading reports for the commit 2041140 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #665      +/-   ##
==========================================
+ Coverage   74.23%   74.24%   +0.01%     
==========================================
  Files          97       97              
  Lines       13120    13127       +7     
==========================================
+ Hits         9739     9746       +7     
  Misses       2692     2692              
  Partials      689      689              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

date := time.Unix(0, msg.Timestamp*1000000).UTC()
var date time.Time

if len(strconv.FormatInt(msg.Timestamp, 10)) > 12 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little odd to convert an int to a string to do a length check when you could do...

if msg.Timestamp > 1_000_000_000_000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the right number to use is 100_000_000_000 that we cannot consider as milliseconds
after experimenting with https://www.epochconverter.com/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg I didn't see you'd changed this again when I hit merge... what's wrong with 1_000_000_000_000 ? That's never going to be a timestamp in seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100_000_000_000 is the first that is matched as milliseconds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

99_999_999_999 should us seconds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be the year 5138 in seconds...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I hear the UNIX timestamp will be broken around 2038, I guess the current achieve that for now

however the correct number to use that should always be detected as seconds is 100_000_000_000

@norkans7 norkans7 force-pushed the fix-FBA-referral-dates branch from 94b8095 to e13b8c5 Compare December 4, 2023 14:41
@norkans7 norkans7 force-pushed the fix-FBA-referral-dates branch from e13b8c5 to 2041140 Compare December 4, 2023 14:45
@rowanseymour rowanseymour merged commit 6689928 into main Dec 4, 2023
5 checks passed
@rowanseymour rowanseymour deleted the fix-FBA-referral-dates branch December 4, 2023 14:48
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants