]> Cypherpunks repositories - gostls13.git/commitdiff
time: set Local.name on windows
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 13 May 2016 04:26:30 +0000 (14:26 +1000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 14 May 2016 17:30:16 +0000 (17:30 +0000)
Local.String() returns "Local" on every OS, but windows.
Change windows code to do like others.

Updates #15568

Change-Id: I7a4d2713d940e2a01cff9d7f5cefc89def07546a
Reviewed-on: https://go-review.googlesource.com/23078
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/time/zoneinfo_test.go
src/time/zoneinfo_windows.go

index 0b7584ab9c2ffdc2927fe6a37506fcab05cea2c9..4b50dc509002f00877e67277dcd8331cc31170cc 100644 (file)
@@ -61,3 +61,12 @@ func TestFirstZone(t *testing.T) {
                }
        }
 }
+
+func TestLocationNames(t *testing.T) {
+       if time.Local.String() != "Local" {
+               t.Errorf(`invalid Local location name: got %q want "Local"`, time.Local)
+       }
+       if time.UTC.String() != "UTC" {
+               t.Errorf(`invalid UTC location name: got %q want "UTC"`, time.UTC)
+       }
+}
index c753119d5db76530d7aaf24a1dca95063f13c701..a6546f54b86ac79cb57f8dcee1e2885665e78644 100644 (file)
@@ -140,6 +140,8 @@ func pseudoUnix(year int, d *syscall.Systemtime) int64 {
 func initLocalFromTZI(i *syscall.Timezoneinformation) {
        l := &localLoc
 
+       l.name = "Local"
+
        nzone := 1
        if i.StandardDate.Month > 0 {
                nzone++