Skip to content

time: clarify docs about standard time #4364

@gopherbot

Description

@gopherbot

by agm@google.com:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Try to make sense of the time.Format (for time.Parse) documentation.
2.
3.

What is the expected output?

Documentation states that the time formats are for a specific time. That is:

   Mon Jan 2 15:04:05 MST 2006
   which is Unix time 1136243045

However, this disagrees with the GNU date tool:

   $ date --date="Mon Jan 2 15:04:05 MST 2006" +%s
   1136239445

A difference of an hour (1136239445 - 1136243045 = -3600).

I was trying to use a "UTC" format "YYYY-MM-DD HH:mm:dd", and
thought (based on this documentation) that I should supply the date string for the
canonical time (in UTC). It wasn't clear based on this discrepancy whether that time was:

   "2006-01-02 22:04:05" (1136239445)

or

   "2006-01-02 23:04:05" (1136243045)

It turns out, the format I need is:

   "2006-01-02 15:04:05"

which seems to pretty much ignore the canonical time... I feel the documentation could
be more clear here. Thanks.

Which compiler are you using (5g, 6g, 8g, gccgo)?

Documentation from the golang website.

Which operating system are you using?

Linux

Which version are you using?  (run 'go version')


Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions