Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: time.Parse: poor error message for invalid string #4493
I have encountered a problem while trying to unmarshall time strings from json. In some cases, the error output is inaccurate. What steps will reproduce the problem? 1. create a json string containing a time string value. 2. try to unmarshall the json into a struct containing a time.Time var. 3. put a time string that does not match the default format (in my case the error is in the timezone part), and the error output fails to indicate the error properly. My test program is available here: http://play.golang.org/p/lIjVVFA1UF What is the expected output? parsing time ""2006-01-02T15:04:05Z07:00"" as ""2006-01-02T15:04:05Z07:00"": cannot parse "07:00"" as """ What do you see instead? parsing time ""2006-01-02T15:04:05Z07:00"" as ""2006-01-02T15:04:05Z07:00"": cannot parse "" as """ Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? Linux 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux Which version are you using? (run 'go version') go version go1 Please provide any additional information below. I have found a fix to get the result i desire, but i am not sure this is the best way to fix it. What i did is go to src/pkg/time/format.go and modify the skip function. I replaced both occurences of `return "", errBad` with `return value, errBad`
Z07:00 is the notation we use to mean 'either a Z or �hh:mm'. It is a time pattern but it is not a valid time. See the bottom of 'godoc time RFC3339' for more. This program demonstrates the three valid inputs: http://play.golang.org/p/Z713W74KF7.
Status changed to WorkingAsIntended.