-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: RFC1123{,Z} format strings appear to be very slightly wrong #67887
Comments
Change https://go.dev/cl/591335 mentions this issue: |
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Duplicate of #34459. In particular note #34459 (comment), which points out that the doc comment already says:
|
…for parsing When using time.RFC1123Z to parse the date header value out of an email, an error is returned for dates that occur in the first 9 days of a month. This is because the format strings for RFC 1123 defined in the time package indicate that the day should be prefixed with a leading 0. Reading the spec, the line that talks about it seems to indicate that days can be either 1 or 2 digits: `date = 1*2DIGIT month 2*4DIGIT` So a date header with a day like `7` with no leading zero should be accepted. Fixes #67887 Change-Id: Ie7ee40d94da2c8c0417957e8b89f9987314949c8 GitHub-Last-Rev: 22a5a52 GitHub-Pull-Request: #67888 Reviewed-on: https://go-review.googlesource.com/c/go/+/591335 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
Go version
go version go1.22.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
We have been using
time.RFC1123Z
to parse theDate
header of emails.We found that sometimes this would work, and sometimes it would not. I tracked this down to "the time of the month". Specifically, if you try to parse an email date from days 1 - 9 of the month,
time.Parse()
withtime.RFC1123Z
throws an error, but on days 10 - 3x, it parses just fine.Specifically, it seems that this part of RFC 1123 indicates that the day can
only be 2 digits if the first is a '1'one or two digits:date = 1*2DIGIT month 2*4DIGIT
This means that a Date string (that I pulled from one of my emails) like this doesn't parse:
Fri, 7 Jun 2024 13:04:42 -0400
But this will:
Fri, 31 May 2024 09:57:48 +0000
What did you see happen?
Most of the time this works, but sometimes it does not.
What did you expect to see?
It should always work, since RFC 1123 defines the date / time expected in an email header.
The text was updated successfully, but these errors were encountered: