You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected this code to successfully parse both times, as they are equivalent according to RFC3339.
What did you see instead?
"2020-09-08T15:52:43-07:00" was successfully parsed.
"2020-09-08 15:52:43-07:00" failed with the following error:
Failed to parse "2020-09-08 15:52:43-07:00", error: parsing time "2020-09-08 15:52:43-07:00" as "2006-01-02T15:04:05Z07:00": cannot parse " 15:52:43-07:00" as "T"
It looks like the parser fails to recognize the optional nature of the T and instead attempts to parse the entire time section of the string as T, which fails.
NOTE: ISO 8601 defines date and time separated by "T".
Applications using this syntax may choose, for the sake of
readability, to specify a full-date and full-time separated by
(say) a space character.
The text was updated successfully, but these errors were encountered:
As the docs say: "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 and they do accept time formats not formally defined."
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to parse an RFC3339-compliant time with the
RFC3339
formatter in thetime
library.Specifically:
time.Parse(time.RFC3339, "2020-09-08 15:52:43-07:00")
See https://play.golang.org/p/cFo1Pd0ciKa for the full code snippet.
Code snippet also pasted here
What did you expect to see?
I expected this code to successfully parse both times, as they are equivalent according to RFC3339.
What did you see instead?
"2020-09-08T15:52:43-07:00" was successfully parsed.
"2020-09-08 15:52:43-07:00" failed with the following error:
It looks like the parser fails to recognize the optional nature of the
T
and instead attempts to parse the entire time section of the string asT
, which fails.From https://tools.ietf.org/html/rfc3339#section-5 section 5.6:
The text was updated successfully, but these errors were encountered: