-
Notifications
You must be signed in to change notification settings - Fork 18k
time: ParseDuration fails for large strings #15011
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
Comments
/cc @robpike |
From what i remember when changing ParseDuration it does not use infinite precision math: |
Hi, thanks for checking this. I understand that there is no benefit in using so many digits. I found the issue because I was parsing the duration as I got it from somewhere else and this string came. However, it seems that this case also fails, but it is a valid time inside precision (59 seconds and one nanosecond, expressed in hours): http://play.golang.org/p/xCp_XyTxXC. If you start removing the last digits, you get 59s, not 59s1ns. You can get 59s1ns if you round it by hand (http://play.golang.org/p/kD8r2ShnNB). I don't know if these cases should be managed by ParseDuration (and Parse may have the same issue). |
CL https://golang.org/cl/29338 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
go version
)?go 1.6
go env
)?Ubuntu x64 but it fails on play.golang.org too.
I ran http://play.golang.org/p/N0A7ph_xkj which contains a large string (not really that large) to be parsed.
Duration parsed with no errors. It works if you remove the last number of duration.
2009/11/10 23:00:00 time: invalid duration 0.12345678912345678912h
The text was updated successfully, but these errors were encountered: