-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: Parse does not cover all valid RFC1123Z dates #34459
Comments
RFC822 also allow day to be one or two digits:
For date fix is trivial but we don't have placeholder for 2 or 4 digits year. On another way RFC1123 say:
So maybe its not needed to implement it. |
FWIW, you can define your own constant without the zero padding. That can parse both zero padded and single digit days. https://play.golang.org/p/gTZHbhp7J5C |
@agnivade I already did bodqhrohro/smstree@5f28f5b |
I think the compatibility guidelines make it hard to fix this constant. We could add another one, but I don't think it's worth it. As already said, it's easy to write one's own. |
Okay, but it would be good to add a notice to documentation, that the constants don't completely conform the standards and should be used with caution. I was lucky to discover it this early, but others may be less lucky. |
This seems related to #20869. Note that the documentation already explicitly says "RFC3339, RFC822, RFC822Z, RFC1123, and RFC1123Z are useful for formatting; when used with time.Parse they do not accept all the time formats permitted by the RFCs." (https://golang.org/pkg/time/#pkg-constants). I don't really see anything else to do here. |
Didn't notice that, sorry. Then yes, there's nothing to do right now. Though, would it be added in the roadmap for a next major release, if it is planned already? |
Given that at least three of us chimed in on this issue without noticing the documentation, I'd say that the documentation is not very discoverable — that particular section is so verbose that this (perhaps important) detail ended up buried. That said, I don't see a way to make it more concise without dropping something equally important, so closing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Probably, as I got the same behavior at Playground.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/aaUf5zpzKXj
What did you expect to see?
According to the standard, a one-digit day is valid.
What did you see instead?
The text was updated successfully, but these errors were encountered: