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
time: ParseDuration fails to parse values consisting of multiple zeros #14209
Comments
Hmm, flipside of how the parser works, it accepts crazy values like |
Is accepting values like |
It might not be covered by Go 1 guarantee explicitly, but as code might
depend on such behavior, we cannot change it.
|
:-( I just got done typing up an EBNF:
|
If it's a bug, we can fix it. The value 00 not being the same as 0 seems like a bug to me, especially for a time value, where 00 is often seen. |
Okay. This seems like a pretty simple bug to fix. I've never submitted a Go patch before so I'll have to read all the contributor docs and whatnot first, but I'll try reading them this weekend and see how far I can get. One question: should I also have it accept |
Note to self, here's a minimal change that seems to fix it: http://play.golang.org/p/L36TxtuMcY |
FTR, I was referring to the "1s2s3s" case that we can't change. I agree
that not being able to parse "00" is a bug.
|
CL https://golang.org/cl/19314 mentions this issue. |
Based on CL 19314, I think this is not a bug. |
time.ParseDuration returns an error when passed a string consisting of more than one zero but no unit: "time: missing unit in duration 00"
See http://play.golang.org/p/_UklkYQ0I1
I'd expect this to have the same behaviour as parsing a single zero, i.e. return a duration of 0 and no error. Leading zeros are ignored as expected when the supplied string has a unit.
go version go1.5.2 linux/amd64
The text was updated successfully, but these errors were encountered: