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 parsing of negative nanos duration #25

Merged
merged 3 commits into from
Nov 20, 2023
Merged

Fix parsing of negative nanos duration #25

merged 3 commits into from
Nov 20, 2023

Conversation

Alfus
Copy link
Contributor

@Alfus Alfus commented Nov 18, 2023

And update fuzz/combinatorial tests to hit this case. It is unfortunate that the built in duration parsing doesn't have enough precision to use directly.

@Alfus Alfus requested a review from jhump November 18, 2023 18:16
return errors.New("missing trailing 's'")
}
value := txt[:len(txt)-1]
isNeg := strings.HasPrefix(value, "-")
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why was this change needed? Why was it not sufficient to just lean on the sign of the parsed seconds value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because there is no -0 in integers.

@Alfus Alfus merged commit 75b473c into main Nov 20, 2023
5 checks passed
@Alfus Alfus deleted the alfus/nnanos branch November 20, 2023 02:09
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.

None yet

2 participants