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

Better handling of millis and micros #68

Merged
merged 3 commits into from
May 12, 2022
Merged

Conversation

wilwade
Copy link
Member

@wilwade wilwade commented May 12, 2022

Problem

TIMESTAMP_MICROS would not always handle bigint correctly.

From: ZJONSSON#58

Solution

Cleanup the code some

Change summary:

  • Fix up TIMESTAMP_MICROS functions
  • Fix toPrimitive_TIME_MILLIS to better handle overflows.

lib/types.ts Outdated
}
}

function fromPrimitive_TIMESTAMP_MICROS(value: number | bigint) {
return typeof value === 'bigint' ? new Date(Number(value / 1000n)): new Date(value / 1000);
if (value === undefined) return new Date(NaN);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can value be undefined?

Copy link
Member Author

Choose a reason for hiding this comment

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

... Checking... Nope! It cannot be (even at runtime). Line 196 of that file catches that. Removing that line.

@wilwade wilwade merged commit 73cf70d into main May 12, 2022
@wilwade wilwade deleted the bug/handle-millis-micros-11 branch May 12, 2022 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants