Skip to content

time: cannot roundtrip Parse the Time.String output #20876

@dsnet

Description

@dsnet

Regression from Go1.8.

On tip, the documentation of Time.String says:

String returns the time formatted using the format string: "2006-01-02 15:04:05.999999999 -0700 MST"

This is misleading since it suggests that the following should work:

time.Parse("2006-01-02 15:04:05.999999999 -0700 MST", time.Now().String())

However, this does not work on Go1.9 since:

parsing time "2017-06-30 17:31:36.969388848 -0700 PDT m=+0.004118679": extra text:  m=+0.004118679

We should done one of the following:

  • Say that round-trip parsing does not work and fix the documentation on Time.String to not suggest that the format string is "2006-01-02 15:04:05.999999999 -0700 MST". We can suggest that String is intended only for human consumption and is not meant to be machine readable.
  • Or fix the API for Parse, such that the monotonic timestamps can be ignored.

\cc @bradfitz @rsc

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions