mirror of
https://github.com/golang/go
synced 2024-11-19 02:14:43 -07:00
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
This commit is contained in:
parent
62be54a8c0
commit
1660ece769
@ -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
|
|
@ -7,22 +7,26 @@
|
|||||||
//
|
//
|
||||||
// usage:
|
// 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"flag"
|
||||||
|
"go/format"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var filename = flag.String("output", "zoneinfo_abbrs_windows.go", "output file name")
|
||||||
|
|
||||||
// getAbbrs finds timezone abbreviations (standard and daylight saving time)
|
// getAbbrs finds timezone abbreviations (standard and daylight saving time)
|
||||||
// for location l.
|
// for location l.
|
||||||
func getAbbrs(l *time.Location) (st, dt string) {
|
func getAbbrs(l *time.Location) (st, dt string) {
|
||||||
@ -105,6 +109,7 @@ func readWindowsZones() (zones, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
zs, err := readWindowsZones()
|
zs, err := readWindowsZones()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -117,7 +122,16 @@ func main() {
|
|||||||
wzURL,
|
wzURL,
|
||||||
zs,
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,16 @@ type abbr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var abbrs = map[string]abbr{
|
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
|
"Morocco Standard Time": {"WET", "WEST"}, // Africa/Casablanca
|
||||||
"South Africa Standard Time": {"SAST", "SAST"}, // Africa/Johannesburg
|
"South Africa Standard Time": {"SAST", "SAST"}, // Africa/Johannesburg
|
||||||
"W. Central Africa Standard Time": {"WAT", "WAT"}, // Africa/Lagos
|
"W. Central Africa Standard Time": {"WAT", "WAT"}, // Africa/Lagos
|
||||||
"E. Africa Standard Time": {"EAT", "EAT"}, // Africa/Nairobi
|
"E. Africa Standard Time": {"EAT", "EAT"}, // Africa/Nairobi
|
||||||
|
"Libya Standard Time": {"EET", "EET"}, // Africa/Tripoli
|
||||||
"Namibia Standard Time": {"WAT", "WAST"}, // Africa/Windhoek
|
"Namibia Standard Time": {"WAT", "WAST"}, // Africa/Windhoek
|
||||||
"Alaskan Standard Time": {"AKST", "AKDT"}, // America/Anchorage
|
"Alaskan Standard Time": {"AKST", "AKDT"}, // America/Anchorage
|
||||||
"Paraguay Standard Time": {"PYT", "PYST"}, // America/Asuncion
|
"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
|
"SA Pacific Standard Time": {"COT", "COT"}, // America/Bogota
|
||||||
"Argentina Standard Time": {"ART", "ART"}, // America/Buenos_Aires
|
"Argentina Standard Time": {"ART", "ART"}, // America/Buenos_Aires
|
||||||
"Venezuela Standard Time": {"VET", "VET"}, // America/Caracas
|
"Venezuela Standard Time": {"VET", "VET"}, // America/Caracas
|
||||||
@ -63,7 +64,6 @@ var abbrs = map[string]abbr{
|
|||||||
"Nepal Standard Time": {"NPT", "NPT"}, // Asia/Katmandu
|
"Nepal Standard Time": {"NPT", "NPT"}, // Asia/Katmandu
|
||||||
"North Asia Standard Time": {"KRAT", "KRAT"}, // Asia/Krasnoyarsk
|
"North Asia Standard Time": {"KRAT", "KRAT"}, // Asia/Krasnoyarsk
|
||||||
"Magadan Standard Time": {"MAGT", "MAGT"}, // Asia/Magadan
|
"Magadan Standard Time": {"MAGT", "MAGT"}, // Asia/Magadan
|
||||||
"E. Europe Standard Time": {"EET", "EEST"}, // Asia/Nicosia
|
|
||||||
"N. Central Asia Standard Time": {"NOVT", "NOVT"}, // Asia/Novosibirsk
|
"N. Central Asia Standard Time": {"NOVT", "NOVT"}, // Asia/Novosibirsk
|
||||||
"Myanmar Standard Time": {"MMT", "MMT"}, // Asia/Rangoon
|
"Myanmar Standard Time": {"MMT", "MMT"}, // Asia/Rangoon
|
||||||
"Arab Standard Time": {"AST", "AST"}, // Asia/Riyadh
|
"Arab Standard Time": {"AST", "AST"}, // Asia/Riyadh
|
||||||
@ -105,11 +105,12 @@ var abbrs = map[string]abbr{
|
|||||||
"Romance Standard Time": {"CET", "CEST"}, // Europe/Paris
|
"Romance Standard Time": {"CET", "CEST"}, // Europe/Paris
|
||||||
"Central European Standard Time": {"CET", "CEST"}, // Europe/Warsaw
|
"Central European Standard Time": {"CET", "CEST"}, // Europe/Warsaw
|
||||||
"Mauritius Standard Time": {"MUT", "MUT"}, // Indian/Mauritius
|
"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
|
"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
|
"Central Pacific Standard Time": {"SBT", "SBT"}, // Pacific/Guadalcanal
|
||||||
"Hawaiian Standard Time": {"HST", "HST"}, // Pacific/Honolulu
|
"Hawaiian Standard Time": {"HST", "HST"}, // Pacific/Honolulu
|
||||||
|
"Line Islands Standard Time": {"LINT", "LINT"}, // Pacific/Kiritimati
|
||||||
"West Pacific Standard Time": {"PGT", "PGT"}, // Pacific/Port_Moresby
|
"West Pacific Standard Time": {"PGT", "PGT"}, // Pacific/Port_Moresby
|
||||||
"Tonga Standard Time": {"TOT", "TOT"}, // Pacific/Tongatapu
|
"Tonga Standard Time": {"TOT", "TOT"}, // Pacific/Tongatapu
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run genzabbrs.go -output zoneinfo_abbrs_windows.go
|
||||||
|
|
||||||
// TODO(rsc): Fall back to copy of zoneinfo files.
|
// TODO(rsc): Fall back to copy of zoneinfo files.
|
||||||
|
|
||||||
// BUG(brainman,rsc): On Windows, the operating system does not provide complete
|
// BUG(brainman,rsc): On Windows, the operating system does not provide complete
|
||||||
|
Loading…
Reference in New Issue
Block a user