Skip to content

time: Parse of RFC3339 and RFC3339Nano are not identical for nanoseconds #54567

@dsnet

Description

@dsnet

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions