1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 // go run genzabbrs.go -output zoneinfo_abbrs_windows.go
29 var filename = flag.String("output", "zoneinfo_abbrs_windows.go", "output file name")
31 // getAbbrs finds timezone abbreviations (standard and daylight saving time)
33 func getAbbrs(l *time.Location) (st, dt string) {
34 t := time.Date(time.Now().Year(), 0, 1, 0, 0, 0, 0, l)
35 abbr1, off1 := t.Zone()
36 for i := 0; i < 12; i++ {
37 t = t.AddDate(0, 1, 0)
38 abbr2, off2 := t.Zone()
40 if off2-off1 < 0 { // southern hemisphere
41 abbr1, abbr2 = abbr2, abbr1
56 const wzURL = "https://raw.githubusercontent.com/unicode-org/cldr/main/common/supplemental/windowsZones.xml"
59 Other string `xml:"other,attr"`
60 Territory string `xml:"territory,attr"`
61 Type string `xml:"type,attr"`
64 type SupplementalData struct {
65 Zones []MapZone `xml:"windowsZones>mapTimezones>mapZone"`
68 func readWindowsZones() ([]*zone, error) {
69 r, err := http.Get(wzURL)
75 data, err := io.ReadAll(r.Body)
80 var sd SupplementalData
81 err = xml.Unmarshal(data, &sd)
85 zs := make([]*zone, 0)
86 for _, z := range sd.Zones {
87 if z.Territory != "001" {
88 // to avoid dups. I don't know why.
91 l, err := time.LoadLocation(z.Type)
96 zs = append(zs, &zone{
108 zs, err := readWindowsZones()
112 sort.Slice(zs, func(i, j int) bool {
113 return zs[i].UnixName < zs[j].UnixName
123 err = template.Must(template.New("prog").Parse(prog)).Execute(&buf, v)
127 data, err := format.Source(buf.Bytes())
131 err = os.WriteFile(*filename, data, 0644)
138 // Copyright 2013 The Go Authors. All rights reserved.
139 // Use of this source code is governed by a BSD-style
140 // license that can be found in the LICENSE file.
142 // Code generated by genzabbrs.go; DO NOT EDIT.
143 // Based on information from {{.URL}}
152 var abbrs = map[string]abbr{
153 {{range .Zs}} "{{.WinName}}": {"{{.StTime}}", "{{.DSTime}}"}, // {{.UnixName}}