]> Cypherpunks repositories - gostls13.git/commitdiff
time: add doc comment about tzdata package
authorLeigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
Wed, 29 Sep 2021 02:19:34 +0000 (02:19 +0000)
committerHeschi Kreinick <heschi@google.com>
Thu, 30 Sep 2021 15:03:39 +0000 (15:03 +0000)
Add doc comment about the time/tzdata package to the time.LoadLocation
function. The time.LoadLocation function was changed in Go 1.15 to add an extra
source that it considers for the time zone database. That location is the
time/tzdata package. It is not easy to discover this behavior because the
documentation for the time package doesn't mention it in the discussion on the
time.LoadLocation function when discussing the different sources. It would be helpful to
describe all possible sources that time.LoadLocation considers when loading the
time zone database, and so I think it would be worthwhile to mention
time/tzdata.

Change-Id: I408fbe188bf9d4ba797e59ec17eb677136d6a9c2
GitHub-Last-Rev: 3dac204326960a18c4e44d3ea24fd428e91e9fcb
GitHub-Pull-Request: golang/go#48673
Reviewed-on: https://go-review.googlesource.com/c/go/+/352830
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

src/time/zoneinfo.go

index 57aed03fec36cc5300913fc5c12b48febb6b4e3f..7b39f869e644fb62d90345d5741c861fa40dcb75 100644 (file)
@@ -631,12 +631,13 @@ var zoneinfoOnce sync.Once
 // Otherwise, the name is taken to be a location name corresponding to a file
 // in the IANA Time Zone database, such as "America/New_York".
 //
-// The time zone database needed by LoadLocation may not be
-// present on all systems, especially non-Unix systems.
-// LoadLocation looks in the directory or uncompressed zip file
-// named by the ZONEINFO environment variable, if any, then looks in
-// known installation locations on Unix systems,
-// and finally looks in $GOROOT/lib/time/zoneinfo.zip.
+// LoadLocation looks for the IANA Time Zone database in the following
+// locations in order:
+//
+// - the directory or uncompressed zip file named by the ZONEINFO environment variable
+// - on a Unix system, the system standard installation location
+// - $GOROOT/lib/time/zoneinfo.zip
+// - the time/tzdata package, if it was imported
 func LoadLocation(name string) (*Location, error) {
        if name == "" || name == "UTC" {
                return UTC, nil