Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
time: documentation shows incorrect formatting of RFC3339 that does not parse #22135
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
@ianlancetaylor #9346 was "frozen due to age" so PLEASE do not close this issue in favor of that other issue. I would like to keep this issue open since it doesn't seem like the other issue was resolved and we can't comment on it now since it was frozen due to age.
So I see two issues here:
If the second bullet point doesn't hold, then
I should be able to read this file back in and Parse back my time strings into time objects so I can use them. If I cannot, then time.Parse is risky and not useful for serialization. Even if this just applies to RFC3339, I really feel that we should fix this edge case/bug in RFC3339.
I'm happy to help with a PR for a doc or code change if somebody can point me in the right direction as to how to get started.
Your second bullet point does not hold. In general
The best way to serialize and deserialize
Edit: Fixed typo in URL.
@ianlancetaylor thanks for responding. When you say "in general, Parse and Format are not inverses of each other", that alarms me. If that's the case, then what's the point of those methods? What is
If you're suggesting that I use
Sorry, I'm not trying to be harsh here, but I'm really surprised to hear that
Thanks again, and I really appreciate your feedback and the work of the go team!
The point of the
If you want to define your own format to interoperate with a non-Go program, then define that format. You should be able to design a format that can use
By the way, I took a closer look at your program, and you are trying to use
@ianlancetaylor thanks for replying. You're right, I did mixup the order of the layout and the value to be parsed (I'd argue that since
Now the output is as follows:
So now the roundtrip within go DOES succeed (yay!) but the sentinel example given in the godoc
Where does the godoc say that "the point of the Format method and Parse function is for producing and parsing human-readable time strings"?
I disagree that "this is not how they are documented". The documentation of the
So maybe the confusion was the the value given in
is NOT actually representative of the values produced by
I'm really not trying to be a PITA here, but I did find this confusing and was very surprise by go's behavior here and I just want to prevent others from having the same confusion.
Thanks again for your help! :-)
Yes, it is confusing, and there have been many dups of #9346.
Fixes to the docs are always welcome, but make sure they are correct.