Commit 1660ece7 authored by Rob Pike's avatar Rob Pike

time: use go generate rather than Makefile (windows only)

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
parent 62be54a8
# 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
......@@ -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)
}
......
......@@ -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
}
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment