]> Cypherpunks repositories - gostls13.git/commitdiff
time: use go generate rather than Makefile (windows only)
authorRob Pike <r@golang.org>
Tue, 26 Aug 2014 21:45:53 +0000 (14:45 -0700)
committerRob Pike <r@golang.org>
Tue, 26 Aug 2014 21:45:53 +0000 (14:45 -0700)
Also make genzabbrs.go more self-contained.
Also run it (on Linux; does that matter?) to update the table.

LGTM=rsc
R=rsc, alex.brainman
CC=golang-codereviews
https://golang.org/cl/128350044

src/pkg/time/Makefile [deleted file]
src/pkg/time/genzabbrs.go
src/pkg/time/zoneinfo_abbrs_windows.go
src/pkg/time/zoneinfo_windows.go

diff --git a/src/pkg/time/Makefile b/src/pkg/time/Makefile
deleted file mode 100644 (file)
index cba58e4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2013 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-genzabbrs: genzabbrs.go
-       go build genzabbrs.go
-
-windows: genzabbrs
-       ./genzabbrs | gofmt >zoneinfo_abbrs_windows.go
index 7c637cb43a7faa6b5ce118c1f9a352f4842430fa..9eb0728a42eed2bcb2db2f29d7c210b72112cc7c 100644 (file)
@@ -7,22 +7,26 @@
 //
 // usage:
 //
-// go run genzabbrs.go | gofmt > $GOROOT/src/pkg/time/zoneinfo_abbrs_windows.go
+// go run genzabbrs.go -output zoneinfo_abbrs_windows.go
 //
 
 package main
 
 import (
+       "bytes"
        "encoding/xml"
+       "flag"
+       "go/format"
        "io/ioutil"
        "log"
        "net/http"
-       "os"
        "sort"
        "text/template"
        "time"
 )
 
+var filename = flag.String("output", "zoneinfo_abbrs_windows.go", "output file name")
+
 // getAbbrs finds timezone abbreviations (standard and daylight saving time)
 // for location l.
 func getAbbrs(l *time.Location) (st, dt string) {
@@ -105,6 +109,7 @@ func readWindowsZones() (zones, error) {
 }
 
 func main() {
+       flag.Parse()
        zs, err := readWindowsZones()
        if err != nil {
                log.Fatal(err)
@@ -117,7 +122,16 @@ func main() {
                wzURL,
                zs,
        }
-       err = template.Must(template.New("prog").Parse(prog)).Execute(os.Stdout, v)
+       var buf bytes.Buffer
+       err = template.Must(template.New("prog").Parse(prog)).Execute(&buf, v)
+       if err != nil {
+               log.Fatal(err)
+       }
+       data, err := format.Source(buf.Bytes())
+       if err != nil {
+               log.Fatal(err)
+       }
+       err = ioutil.WriteFile(*filename, data, 0644)
        if err != nil {
                log.Fatal(err)
        }
index 80334371fe02f5e3d78f950b2ad95f1b25771a0a..df0c10e91c2f8365bd8f5fd630ead8928c074775 100644 (file)
@@ -13,15 +13,16 @@ type abbr struct {
 }
 
 var abbrs = map[string]abbr{
-       "Egypt Standard Time":             {"EET", "EET"},    // Africa/Cairo
+       "Egypt Standard Time":             {"EET", "EEST"},   // Africa/Cairo
        "Morocco Standard Time":           {"WET", "WEST"},   // Africa/Casablanca
        "South Africa Standard Time":      {"SAST", "SAST"},  // Africa/Johannesburg
        "W. Central Africa Standard Time": {"WAT", "WAT"},    // Africa/Lagos
        "E. Africa Standard Time":         {"EAT", "EAT"},    // Africa/Nairobi
+       "Libya Standard Time":             {"EET", "EET"},    // Africa/Tripoli
        "Namibia Standard Time":           {"WAT", "WAST"},   // Africa/Windhoek
        "Alaskan Standard Time":           {"AKST", "AKDT"},  // America/Anchorage
        "Paraguay Standard Time":          {"PYT", "PYST"},   // America/Asuncion
-       "Bahia Standard Time":             {"BRT", "BRST"},   // America/Bahia
+       "Bahia Standard Time":             {"BRT", "BRT"},    // America/Bahia
        "SA Pacific Standard Time":        {"COT", "COT"},    // America/Bogota
        "Argentina Standard Time":         {"ART", "ART"},    // America/Buenos_Aires
        "Venezuela Standard Time":         {"VET", "VET"},    // America/Caracas
@@ -63,7 +64,6 @@ var abbrs = map[string]abbr{
        "Nepal Standard Time":             {"NPT", "NPT"},    // Asia/Katmandu
        "North Asia Standard Time":        {"KRAT", "KRAT"},  // Asia/Krasnoyarsk
        "Magadan Standard Time":           {"MAGT", "MAGT"},  // Asia/Magadan
-       "E. Europe Standard Time":         {"EET", "EEST"},   // Asia/Nicosia
        "N. Central Asia Standard Time":   {"NOVT", "NOVT"},  // Asia/Novosibirsk
        "Myanmar Standard Time":           {"MMT", "MMT"},    // Asia/Rangoon
        "Arab Standard Time":              {"AST", "AST"},    // Asia/Riyadh
@@ -105,11 +105,12 @@ var abbrs = map[string]abbr{
        "Romance Standard Time":          {"CET", "CEST"},      // Europe/Paris
        "Central European Standard Time": {"CET", "CEST"},      // Europe/Warsaw
        "Mauritius Standard Time":        {"MUT", "MUT"},       // Indian/Mauritius
-       "Samoa Standard Time":            {"WST", "WST"},       // Pacific/Apia
+       "Samoa Standard Time":            {"WST", "WSDT"},      // Pacific/Apia
        "New Zealand Standard Time":      {"NZST", "NZDT"},     // Pacific/Auckland
-       "Fiji Standard Time":             {"FJT", "FJT"},       // Pacific/Fiji
+       "Fiji Standard Time":             {"FJT", "FJST"},      // Pacific/Fiji
        "Central Pacific Standard Time":  {"SBT", "SBT"},       // Pacific/Guadalcanal
        "Hawaiian Standard Time":         {"HST", "HST"},       // Pacific/Honolulu
+       "Line Islands Standard Time":     {"LINT", "LINT"},     // Pacific/Kiritimati
        "West Pacific Standard Time":     {"PGT", "PGT"},       // Pacific/Port_Moresby
        "Tonga Standard Time":            {"TOT", "TOT"},       // Pacific/Tongatapu
 }
index 6046743e67d0c9fabe7e1470c96d4a3d58ba4f43..02d8e0edcc891bd9d4ba3fc3d4c453310f04578d 100644 (file)
@@ -11,6 +11,8 @@ import (
        "unsafe"
 )
 
+//go:generate go run genzabbrs.go -output zoneinfo_abbrs_windows.go
+
 // TODO(rsc): Fall back to copy of zoneinfo files.
 
 // BUG(brainman,rsc): On Windows, the operating system does not provide complete