time: time.Parse example misleading about timezone support #18012
Labels
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +75055de Tue Nov 22 04:28:59 2016 +0000 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
Ran the example from time.Parse's documentation on the playground and on a machine set to a timezone other than PST
https://golang.org/pkg/time/#Parse
https://play.golang.org/p/tuBDbz66I0
What did you expect to see?
2013-02-03 19:54:00 -0800 PST
What did you see instead?
2013-02-03 19:54:00 -0000 PST
The issue is that when time.Parse is used with a timezone abbreviation format in a different timezone than the one the abbreviation specifies it will not print a correct offset. For example if the input specifies PST but the code is run on a machine set to MST the offset will be printed as all zeroes (a "fabricated" timezone, as per the documentation). While this is tersely documented, the documentation example provides only the rare "working" case, which is misleading. I suggest a second case is added with a different timezone and the expected output documented in a comment, a minimal (likely insufficient) example:
The text was updated successfully, but these errors were encountered: