time: improve Documentation for Parse for zone offsets #29351
Labels
Documentation
Issues describing a change to documentation.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. Checked master and docs have not changed in tip either.
What did you do?
https://play.golang.org/p/bvmvzOstarf
Edit: the zone in this should be PST, but the result is the same ^
What did you expect to see?
I expected to see the timezone offset to be set accordingly.
What did you see instead?
The timezone numeric offset was not set, despite
Zone()
returning a text zone.Proposal
For those unfamiliar with timezones, we are unaware that timezone abbreviations are ambiguous. The docs make it clear that in order for those textual time zones to be parsed and set an offset, it must be parsed in the context of a location. However, it's not immediately clear that you will have a problem trying to parse dates with a timezone abbreviation.
I propose adding a simple line: "Timezone abbreviations like "MST" are ambiguous, therefore..." to the docs.
go/src/time/format.go
Lines 764 to 772 in 84066f1
We discovered this during a migration from Javascript, which does set a numeric offset even in the absence of a predefined location (servers location is UTC, but still parses PDT as -07:00)
The text was updated successfully, but these errors were encountered: