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

Issue #196 - Fix UI Time64 decode handling of 0 value #197

Merged
merged 1 commit into from
Mar 10, 2021
Merged

Conversation

MJJoyce
Copy link
Member

@MJJoyce MJJoyce commented Mar 5, 2021

Update Time64 decode function's handling of 0 value to prevent a bogus
Date object being created.

Resolve #196

@MJJoyce MJJoyce requested review from a team as code owners March 5, 2021 22:34
@@ -206,7 +206,11 @@ class Time32Type extends TimeType
class Time64Type extends TimeType
{
decode (raw) {
const parts = String(raw).split('.').map(x => parseInt(x))
let parts = [0, 0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is '0' the only case where a decimal would be missing? If not, should the check be for '.', if found, usual logic, otherwise parts = [ parseInt(raw), 0] ?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a very good question @nttoole. I'll poke

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in line with your recommendation @nttoole

If raw % 1 === 0 it's not a float and we need to handle that edge case. Otherwise we stick with the normal approach.

Good catch

Update Time64 decode function's handling of non-float values to prevent a
bogus Date object being created.

Resolve #196
@MJJoyce MJJoyce merged commit 6cfa654 into master Mar 10, 2021
@MJJoyce MJJoyce deleted the issue-196 branch March 10, 2021 17:10
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.

Time64 value handling fails when given a 0 value
2 participants