Skip to content
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 of RFC3339 and RFC3339Nano are not identical for nanoseconds #54567

Closed
dsnet opened this issue Aug 21, 2022 · 1 comment
Closed

Comments

@dsnet
Copy link
Member

dsnet commented Aug 21, 2022

The RFC3339 format implicitly supports parsing of fractional seconds.
Consequently, one would expect that it would behave identically to RFC3339Nano.
However, that is not the case where they differ in behavior for sub-nanosecond digits:

const in = "2021-09-29T16:04:33.0000000000Z"
fmt.Println(time.Parse(time.RFC3339, in))
fmt.Println(time.Parse(time.RFC3339Nano, in))

prints:

2021-09-29 16:04:33 +0000 UTC <nil>
0001-01-01 00:00:00 +0000 UTC parsing time "2021-09-29T16:04:33.0000000000Z" as "2006-01-02T15:04:05.999999999Z07:00": cannot parse "0Z" as "Z07:00"

I expect it to print identical results.

@dsnet dsnet changed the title time: Parse of RFC3339 and RFC3339Nano are not identical time: Parse of RFC3339 and RFC3339Nano are not identical for nanoseconds Aug 21, 2022
@gopherbot
Copy link

Change https://go.dev/cl/425037 mentions this issue: time: fix Parse to ignore extra sub-nanosecond digits

@golang golang locked and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants