Skip to content

time: Document time.Parse leap second behavior #50888

@williambanfield

Description

@williambanfield

go version: go version go1.17.5 linux/amd64

RFC3339 documents that leap seconds will be denoted as YYYY-MM-DDT23:59:60Z. Attempting to parse such a value using time.Parse returns the following error:

parsing time "2022-12-31T23:59:60Z": second out of range

https://go.dev/play/p/es_oGD37vZl

This behavior seems perfectly reasonable, given the fact that Go's time keeping does not account for the leap second and instead uses the Unix style of time. However, while I notice that the documentation for package time mentions that calendrical calculations always assume a Gregorian calendar, with no leap seconds, it doesn't seem to indicate the parser behavior.

I see that issues have been opened in the past to change the behavior, #8728. This issue is just a request that the behavior be documented as part of the time package.

Happy to provide any other information needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions