Checking in vendor folder for ease of using go get.
This commit is contained in:
parent
7a1251853b
commit
cdb4b5a1d0
3554 changed files with 1270116 additions and 0 deletions
335
vendor/golang.org/x/text/date/data_test.go
generated
vendored
Normal file
335
vendor/golang.org/x/text/date/data_test.go
generated
vendored
Normal file
|
@ -0,0 +1,335 @@
|
|||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||
|
||||
package date
|
||||
|
||||
var enumMap = map[string]uint16{
|
||||
"": 0,
|
||||
"calendars": 0,
|
||||
"fields": 1,
|
||||
"timeZoneNames": 2,
|
||||
"buddhist": 0,
|
||||
"chinese": 1,
|
||||
"coptic": 2,
|
||||
"dangi": 3,
|
||||
"ethiopic": 4,
|
||||
"ethiopic-amete-alem": 5,
|
||||
"generic": 6,
|
||||
"gregorian": 7,
|
||||
"hebrew": 8,
|
||||
"indian": 9,
|
||||
"islamic": 10,
|
||||
"islamic-civil": 11,
|
||||
"islamic-rgsa": 12,
|
||||
"islamic-tbla": 13,
|
||||
"islamic-umalqura": 14,
|
||||
"japanese": 15,
|
||||
"persian": 16,
|
||||
"roc": 17,
|
||||
"months": 0,
|
||||
"days": 1,
|
||||
"quarters": 2,
|
||||
"dayPeriods": 3,
|
||||
"eras": 4,
|
||||
"dateFormats": 5,
|
||||
"timeFormats": 6,
|
||||
"dateTimeFormats": 7,
|
||||
"monthPatterns": 8,
|
||||
"cyclicNameSets": 9,
|
||||
"format": 0,
|
||||
"stand-alone": 1,
|
||||
"numeric": 2,
|
||||
"widthAbbreviated": 0,
|
||||
"widthNarrow": 1,
|
||||
"widthWide": 2,
|
||||
"widthAll": 3,
|
||||
"widthShort": 4,
|
||||
"leap7": 0,
|
||||
"sun": 0,
|
||||
"mon": 1,
|
||||
"tue": 2,
|
||||
"wed": 3,
|
||||
"thu": 4,
|
||||
"fri": 5,
|
||||
"sat": 6,
|
||||
"am": 0,
|
||||
"pm": 1,
|
||||
"midnight": 2,
|
||||
"morning1": 3,
|
||||
"afternoon1": 4,
|
||||
"evening1": 5,
|
||||
"night1": 6,
|
||||
"noon": 7,
|
||||
"morning2": 8,
|
||||
"afternoon2": 9,
|
||||
"night2": 10,
|
||||
"evening2": 11,
|
||||
"variant": 1,
|
||||
"short": 0,
|
||||
"long": 1,
|
||||
"full": 2,
|
||||
"medium": 3,
|
||||
"dayPartsCycleType": 0,
|
||||
"daysCycleType": 1,
|
||||
"monthsCycleType": 2,
|
||||
"solarTermsCycleType": 3,
|
||||
"yearsCycleType": 4,
|
||||
"zodiacsCycleType": 5,
|
||||
"eraField": 0,
|
||||
"era-shortField": 1,
|
||||
"era-narrowField": 2,
|
||||
"yearField": 3,
|
||||
"year-shortField": 4,
|
||||
"year-narrowField": 5,
|
||||
"quarterField": 6,
|
||||
"quarter-shortField": 7,
|
||||
"quarter-narrowField": 8,
|
||||
"monthField": 9,
|
||||
"month-shortField": 10,
|
||||
"month-narrowField": 11,
|
||||
"weekField": 12,
|
||||
"week-shortField": 13,
|
||||
"week-narrowField": 14,
|
||||
"weekOfMonthField": 15,
|
||||
"weekOfMonth-shortField": 16,
|
||||
"weekOfMonth-narrowField": 17,
|
||||
"dayField": 18,
|
||||
"day-shortField": 19,
|
||||
"day-narrowField": 20,
|
||||
"dayOfYearField": 21,
|
||||
"dayOfYear-shortField": 22,
|
||||
"dayOfYear-narrowField": 23,
|
||||
"weekdayField": 24,
|
||||
"weekday-shortField": 25,
|
||||
"weekday-narrowField": 26,
|
||||
"weekdayOfMonthField": 27,
|
||||
"weekdayOfMonth-shortField": 28,
|
||||
"weekdayOfMonth-narrowField": 29,
|
||||
"sunField": 30,
|
||||
"sun-shortField": 31,
|
||||
"sun-narrowField": 32,
|
||||
"monField": 33,
|
||||
"mon-shortField": 34,
|
||||
"mon-narrowField": 35,
|
||||
"tueField": 36,
|
||||
"tue-shortField": 37,
|
||||
"tue-narrowField": 38,
|
||||
"wedField": 39,
|
||||
"wed-shortField": 40,
|
||||
"wed-narrowField": 41,
|
||||
"thuField": 42,
|
||||
"thu-shortField": 43,
|
||||
"thu-narrowField": 44,
|
||||
"friField": 45,
|
||||
"fri-shortField": 46,
|
||||
"fri-narrowField": 47,
|
||||
"satField": 48,
|
||||
"sat-shortField": 49,
|
||||
"sat-narrowField": 50,
|
||||
"dayperiod-shortField": 51,
|
||||
"dayperiodField": 52,
|
||||
"dayperiod-narrowField": 53,
|
||||
"hourField": 54,
|
||||
"hour-shortField": 55,
|
||||
"hour-narrowField": 56,
|
||||
"minuteField": 57,
|
||||
"minute-shortField": 58,
|
||||
"minute-narrowField": 59,
|
||||
"secondField": 60,
|
||||
"second-shortField": 61,
|
||||
"second-narrowField": 62,
|
||||
"zoneField": 63,
|
||||
"zone-shortField": 64,
|
||||
"zone-narrowField": 65,
|
||||
"displayName": 0,
|
||||
"relative": 1,
|
||||
"relativeTime": 2,
|
||||
"relativePeriod": 3,
|
||||
"before1": 0,
|
||||
"current": 1,
|
||||
"after1": 2,
|
||||
"before2": 3,
|
||||
"after2": 4,
|
||||
"after3": 5,
|
||||
"future": 0,
|
||||
"past": 1,
|
||||
"other": 0,
|
||||
"one": 1,
|
||||
"zero": 2,
|
||||
"two": 3,
|
||||
"few": 4,
|
||||
"many": 5,
|
||||
"zoneFormat": 0,
|
||||
"regionFormat": 1,
|
||||
"zone": 2,
|
||||
"metaZone": 3,
|
||||
"hourFormat": 0,
|
||||
"gmtFormat": 1,
|
||||
"gmtZeroFormat": 2,
|
||||
"genericTime": 0,
|
||||
"daylightTime": 1,
|
||||
"standardTime": 2,
|
||||
"Etc/UTC": 0,
|
||||
"Europe/London": 1,
|
||||
"Europe/Dublin": 2,
|
||||
"Pacific/Honolulu": 3,
|
||||
"Afghanistan": 0,
|
||||
"Africa_Central": 1,
|
||||
"Africa_Eastern": 2,
|
||||
"Africa_Southern": 3,
|
||||
"Africa_Western": 4,
|
||||
"Alaska": 5,
|
||||
"Amazon": 6,
|
||||
"America_Central": 7,
|
||||
"America_Eastern": 8,
|
||||
"America_Mountain": 9,
|
||||
"America_Pacific": 10,
|
||||
"Anadyr": 11,
|
||||
"Apia": 12,
|
||||
"Arabian": 13,
|
||||
"Argentina": 14,
|
||||
"Argentina_Western": 15,
|
||||
"Armenia": 16,
|
||||
"Atlantic": 17,
|
||||
"Australia_Central": 18,
|
||||
"Australia_CentralWestern": 19,
|
||||
"Australia_Eastern": 20,
|
||||
"Australia_Western": 21,
|
||||
"Azerbaijan": 22,
|
||||
"Azores": 23,
|
||||
"Bangladesh": 24,
|
||||
"Bhutan": 25,
|
||||
"Bolivia": 26,
|
||||
"Brasilia": 27,
|
||||
"Brunei": 28,
|
||||
"Cape_Verde": 29,
|
||||
"Chamorro": 30,
|
||||
"Chatham": 31,
|
||||
"Chile": 32,
|
||||
"China": 33,
|
||||
"Choibalsan": 34,
|
||||
"Christmas": 35,
|
||||
"Cocos": 36,
|
||||
"Colombia": 37,
|
||||
"Cook": 38,
|
||||
"Cuba": 39,
|
||||
"Davis": 40,
|
||||
"DumontDUrville": 41,
|
||||
"East_Timor": 42,
|
||||
"Easter": 43,
|
||||
"Ecuador": 44,
|
||||
"Europe_Central": 45,
|
||||
"Europe_Eastern": 46,
|
||||
"Europe_Further_Eastern": 47,
|
||||
"Europe_Western": 48,
|
||||
"Falkland": 49,
|
||||
"Fiji": 50,
|
||||
"French_Guiana": 51,
|
||||
"French_Southern": 52,
|
||||
"Galapagos": 53,
|
||||
"Gambier": 54,
|
||||
"Georgia": 55,
|
||||
"Gilbert_Islands": 56,
|
||||
"GMT": 57,
|
||||
"Greenland_Eastern": 58,
|
||||
"Greenland_Western": 59,
|
||||
"Gulf": 60,
|
||||
"Guyana": 61,
|
||||
"Hawaii_Aleutian": 62,
|
||||
"Hong_Kong": 63,
|
||||
"Hovd": 64,
|
||||
"India": 65,
|
||||
"Indian_Ocean": 66,
|
||||
"Indochina": 67,
|
||||
"Indonesia_Central": 68,
|
||||
"Indonesia_Eastern": 69,
|
||||
"Indonesia_Western": 70,
|
||||
"Iran": 71,
|
||||
"Irkutsk": 72,
|
||||
"Israel": 73,
|
||||
"Japan": 74,
|
||||
"Kamchatka": 75,
|
||||
"Kazakhstan_Eastern": 76,
|
||||
"Kazakhstan_Western": 77,
|
||||
"Korea": 78,
|
||||
"Kosrae": 79,
|
||||
"Krasnoyarsk": 80,
|
||||
"Kyrgystan": 81,
|
||||
"Line_Islands": 82,
|
||||
"Lord_Howe": 83,
|
||||
"Macquarie": 84,
|
||||
"Magadan": 85,
|
||||
"Malaysia": 86,
|
||||
"Maldives": 87,
|
||||
"Marquesas": 88,
|
||||
"Marshall_Islands": 89,
|
||||
"Mauritius": 90,
|
||||
"Mawson": 91,
|
||||
"Mexico_Northwest": 92,
|
||||
"Mexico_Pacific": 93,
|
||||
"Mongolia": 94,
|
||||
"Moscow": 95,
|
||||
"Myanmar": 96,
|
||||
"Nauru": 97,
|
||||
"Nepal": 98,
|
||||
"New_Caledonia": 99,
|
||||
"New_Zealand": 100,
|
||||
"Newfoundland": 101,
|
||||
"Niue": 102,
|
||||
"Norfolk": 103,
|
||||
"Noronha": 104,
|
||||
"Novosibirsk": 105,
|
||||
"Omsk": 106,
|
||||
"Pakistan": 107,
|
||||
"Palau": 108,
|
||||
"Papua_New_Guinea": 109,
|
||||
"Paraguay": 110,
|
||||
"Peru": 111,
|
||||
"Philippines": 112,
|
||||
"Phoenix_Islands": 113,
|
||||
"Pierre_Miquelon": 114,
|
||||
"Pitcairn": 115,
|
||||
"Ponape": 116,
|
||||
"Pyongyang": 117,
|
||||
"Reunion": 118,
|
||||
"Rothera": 119,
|
||||
"Sakhalin": 120,
|
||||
"Samara": 121,
|
||||
"Samoa": 122,
|
||||
"Seychelles": 123,
|
||||
"Singapore": 124,
|
||||
"Solomon": 125,
|
||||
"South_Georgia": 126,
|
||||
"Suriname": 127,
|
||||
"Syowa": 128,
|
||||
"Tahiti": 129,
|
||||
"Taipei": 130,
|
||||
"Tajikistan": 131,
|
||||
"Tokelau": 132,
|
||||
"Tonga": 133,
|
||||
"Truk": 134,
|
||||
"Turkmenistan": 135,
|
||||
"Tuvalu": 136,
|
||||
"Uruguay": 137,
|
||||
"Uzbekistan": 138,
|
||||
"Vanuatu": 139,
|
||||
"Venezuela": 140,
|
||||
"Vladivostok": 141,
|
||||
"Volgograd": 142,
|
||||
"Vostok": 143,
|
||||
"Wake": 144,
|
||||
"Wallis": 145,
|
||||
"Yakutsk": 146,
|
||||
"Yekaterinburg": 147,
|
||||
"Guam": 148,
|
||||
"North_Mariana": 149,
|
||||
"Acre": 150,
|
||||
"Almaty": 151,
|
||||
"Aqtau": 152,
|
||||
"Aqtobe": 153,
|
||||
"Casey": 154,
|
||||
"Lanka": 155,
|
||||
"Macau": 156,
|
||||
"Qyzylorda": 157,
|
||||
}
|
||||
|
||||
// Total table size 0 bytes (0KiB); checksum: 811C9DC5
|
329
vendor/golang.org/x/text/date/gen.go
generated
vendored
Normal file
329
vendor/golang.org/x/text/date/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,329 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/internal/cldrtree"
|
||||
"golang.org/x/text/internal/gen"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/unicode/cldr"
|
||||
)
|
||||
|
||||
var (
|
||||
draft = flag.String("draft",
|
||||
"contributed",
|
||||
`Minimal draft requirements (approved, contributed, provisional, unconfirmed).`)
|
||||
)
|
||||
|
||||
// TODO:
|
||||
// - Compile format patterns.
|
||||
// - Compress the large amount of redundancy in metazones.
|
||||
// - Split trees (with shared buckets) with data that is enough for default
|
||||
// formatting of Go Time values and and tables that are needed for larger
|
||||
// variants.
|
||||
// - zone to metaZone mappings (in supplemental)
|
||||
// - Add more enum values and also some key maps for some of the elements.
|
||||
|
||||
func main() {
|
||||
gen.Init()
|
||||
|
||||
r := gen.OpenCLDRCoreZip()
|
||||
defer r.Close()
|
||||
|
||||
d := &cldr.Decoder{}
|
||||
d.SetDirFilter("supplemental", "main")
|
||||
d.SetSectionFilter("dates")
|
||||
data, err := d.DecodeZip(r)
|
||||
if err != nil {
|
||||
log.Fatalf("DecodeZip: %v", err)
|
||||
}
|
||||
|
||||
dates := cldrtree.New("dates")
|
||||
buildCLDRTree(data, dates)
|
||||
|
||||
w := gen.NewCodeWriter()
|
||||
if err := dates.Gen(w); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gen.WriteCLDRVersion(w)
|
||||
w.WriteGoFile("tables.go", "date")
|
||||
|
||||
w = gen.NewCodeWriter()
|
||||
if err := dates.GenTestData(w); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w.WriteGoFile("data_test.go", "date")
|
||||
}
|
||||
|
||||
func buildCLDRTree(data *cldr.CLDR, dates *cldrtree.Builder) {
|
||||
context := cldrtree.Enum("context")
|
||||
widthMap := func(s string) string {
|
||||
// Align era with width values.
|
||||
if r, ok := map[string]string{
|
||||
"eraAbbr": "abbreviated",
|
||||
"eraNarrow": "narrow",
|
||||
"eraNames": "wide",
|
||||
}[s]; ok {
|
||||
s = r
|
||||
}
|
||||
// Prefix width to disambiguate with some overlapping length values.
|
||||
return "width" + strings.Title(s)
|
||||
}
|
||||
width := cldrtree.EnumFunc("width", widthMap, "abbreviated", "narrow", "wide")
|
||||
length := cldrtree.Enum("length", "short", "long")
|
||||
month := cldrtree.Enum("month", "leap7")
|
||||
relTime := cldrtree.EnumFunc("relTime", func(s string) string {
|
||||
x, err := strconv.ParseInt(s, 10, 8)
|
||||
if err != nil {
|
||||
log.Fatal("Invalid number:", err)
|
||||
}
|
||||
return []string{
|
||||
"before2",
|
||||
"before1",
|
||||
"current",
|
||||
"after1",
|
||||
"after2",
|
||||
"after3",
|
||||
}[x+2]
|
||||
})
|
||||
// Disambiguate keys like 'months' and 'sun'.
|
||||
cycleType := cldrtree.EnumFunc("cycleType", func(s string) string {
|
||||
return s + "CycleType"
|
||||
})
|
||||
field := cldrtree.EnumFunc("field", func(s string) string {
|
||||
return s + "Field"
|
||||
})
|
||||
timeType := cldrtree.EnumFunc("timeType", func(s string) string {
|
||||
if s == "" {
|
||||
return "genericTime"
|
||||
}
|
||||
return s + "Time"
|
||||
}, "generic")
|
||||
|
||||
zoneType := []cldrtree.Option{cldrtree.SharedType(), timeType}
|
||||
metaZoneType := []cldrtree.Option{cldrtree.SharedType(), timeType}
|
||||
|
||||
for _, lang := range data.Locales() {
|
||||
tag := language.Make(lang)
|
||||
ldml := data.RawLDML(lang)
|
||||
if ldml.Dates == nil {
|
||||
continue
|
||||
}
|
||||
x := dates.Locale(tag)
|
||||
if x := x.Index(ldml.Dates.Calendars); x != nil {
|
||||
for _, cal := range ldml.Dates.Calendars.Calendar {
|
||||
x := x.IndexFromType(cal)
|
||||
if x := x.Index(cal.Months); x != nil {
|
||||
for _, mc := range cal.Months.MonthContext {
|
||||
x := x.IndexFromType(mc, context)
|
||||
for _, mw := range mc.MonthWidth {
|
||||
x := x.IndexFromType(mw, width)
|
||||
for _, m := range mw.Month {
|
||||
x.SetValue(m.Yeartype+m.Type, m, month)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.MonthPatterns); x != nil {
|
||||
for _, mc := range cal.MonthPatterns.MonthPatternContext {
|
||||
x := x.IndexFromType(mc, context)
|
||||
for _, mw := range mc.MonthPatternWidth {
|
||||
// Value is always leap, so no need to create a
|
||||
// subindex.
|
||||
for _, m := range mw.MonthPattern {
|
||||
x.SetValue(mw.Type, m, width)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.CyclicNameSets); x != nil {
|
||||
for _, cns := range cal.CyclicNameSets.CyclicNameSet {
|
||||
x := x.IndexFromType(cns, cycleType)
|
||||
for _, cc := range cns.CyclicNameContext {
|
||||
x := x.IndexFromType(cc, context)
|
||||
for _, cw := range cc.CyclicNameWidth {
|
||||
x := x.IndexFromType(cw, width)
|
||||
for _, c := range cw.CyclicName {
|
||||
x.SetValue(c.Type, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.Days); x != nil {
|
||||
for _, dc := range cal.Days.DayContext {
|
||||
x := x.IndexFromType(dc, context)
|
||||
for _, dw := range dc.DayWidth {
|
||||
x := x.IndexFromType(dw, width)
|
||||
for _, d := range dw.Day {
|
||||
x.SetValue(d.Type, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.Quarters); x != nil {
|
||||
for _, qc := range cal.Quarters.QuarterContext {
|
||||
x := x.IndexFromType(qc, context)
|
||||
for _, qw := range qc.QuarterWidth {
|
||||
x := x.IndexFromType(qw, width)
|
||||
for _, q := range qw.Quarter {
|
||||
x.SetValue(q.Type, q)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.DayPeriods); x != nil {
|
||||
for _, dc := range cal.DayPeriods.DayPeriodContext {
|
||||
x := x.IndexFromType(dc, context)
|
||||
for _, dw := range dc.DayPeriodWidth {
|
||||
x := x.IndexFromType(dw, width)
|
||||
for _, d := range dw.DayPeriod {
|
||||
x.IndexFromType(d).SetValue(d.Alt, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.Eras); x != nil {
|
||||
opts := []cldrtree.Option{width, cldrtree.SharedType()}
|
||||
if x := x.Index(cal.Eras.EraNames, opts...); x != nil {
|
||||
for _, e := range cal.Eras.EraNames.Era {
|
||||
x.IndexFromAlt(e).SetValue(e.Type, e)
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.Eras.EraAbbr, opts...); x != nil {
|
||||
for _, e := range cal.Eras.EraAbbr.Era {
|
||||
x.IndexFromAlt(e).SetValue(e.Type, e)
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.Eras.EraNarrow, opts...); x != nil {
|
||||
for _, e := range cal.Eras.EraNarrow.Era {
|
||||
x.IndexFromAlt(e).SetValue(e.Type, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.DateFormats); x != nil {
|
||||
for _, dfl := range cal.DateFormats.DateFormatLength {
|
||||
x := x.IndexFromType(dfl, length)
|
||||
for _, df := range dfl.DateFormat {
|
||||
for _, p := range df.Pattern {
|
||||
x.SetValue(p.Alt, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.TimeFormats); x != nil {
|
||||
for _, tfl := range cal.TimeFormats.TimeFormatLength {
|
||||
x := x.IndexFromType(tfl, length)
|
||||
for _, tf := range tfl.TimeFormat {
|
||||
for _, p := range tf.Pattern {
|
||||
x.SetValue(p.Alt, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(cal.DateTimeFormats); x != nil {
|
||||
for _, dtfl := range cal.DateTimeFormats.DateTimeFormatLength {
|
||||
x := x.IndexFromType(dtfl, length)
|
||||
for _, dtf := range dtfl.DateTimeFormat {
|
||||
for _, p := range dtf.Pattern {
|
||||
x.SetValue(p.Alt, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:
|
||||
// - appendItems
|
||||
// - intervalFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: this is a lot of data and is probably relatively little used.
|
||||
// Store this somewhere else.
|
||||
if x := x.Index(ldml.Dates.Fields); x != nil {
|
||||
for _, f := range ldml.Dates.Fields.Field {
|
||||
x := x.IndexFromType(f, field)
|
||||
for _, d := range f.DisplayName {
|
||||
x.Index(d).SetValue(d.Alt, d)
|
||||
}
|
||||
for _, r := range f.Relative {
|
||||
x.Index(r).SetValue(r.Type, r, relTime)
|
||||
}
|
||||
for _, rt := range f.RelativeTime {
|
||||
x := x.Index(rt).IndexFromType(rt)
|
||||
for _, p := range rt.RelativeTimePattern {
|
||||
x.SetValue(p.Count, p)
|
||||
}
|
||||
}
|
||||
for _, rp := range f.RelativePeriod {
|
||||
x.Index(rp).SetValue(rp.Alt, rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
if x := x.Index(ldml.Dates.TimeZoneNames); x != nil {
|
||||
format := x.IndexWithName("zoneFormat")
|
||||
for _, h := range ldml.Dates.TimeZoneNames.HourFormat {
|
||||
format.SetValue(h.Element(), h)
|
||||
}
|
||||
for _, g := range ldml.Dates.TimeZoneNames.GmtFormat {
|
||||
format.SetValue(g.Element(), g)
|
||||
}
|
||||
for _, g := range ldml.Dates.TimeZoneNames.GmtZeroFormat {
|
||||
format.SetValue(g.Element(), g)
|
||||
}
|
||||
for _, r := range ldml.Dates.TimeZoneNames.RegionFormat {
|
||||
x.Index(r).SetValue(r.Type, r, timeType)
|
||||
}
|
||||
|
||||
set := func(x *cldrtree.Index, e []*cldr.Common, zone string) {
|
||||
for _, n := range e {
|
||||
x.Index(n, zoneType...).SetValue(zone, n)
|
||||
}
|
||||
}
|
||||
zoneWidth := []cldrtree.Option{length, cldrtree.SharedType()}
|
||||
zs := x.IndexWithName("zone")
|
||||
for _, z := range ldml.Dates.TimeZoneNames.Zone {
|
||||
for _, l := range z.Long {
|
||||
x := zs.Index(l, zoneWidth...)
|
||||
set(x, l.Generic, z.Type)
|
||||
set(x, l.Standard, z.Type)
|
||||
set(x, l.Daylight, z.Type)
|
||||
}
|
||||
for _, s := range z.Short {
|
||||
x := zs.Index(s, zoneWidth...)
|
||||
set(x, s.Generic, z.Type)
|
||||
set(x, s.Standard, z.Type)
|
||||
set(x, s.Daylight, z.Type)
|
||||
}
|
||||
}
|
||||
set = func(x *cldrtree.Index, e []*cldr.Common, zone string) {
|
||||
for _, n := range e {
|
||||
x.Index(n, metaZoneType...).SetValue(zone, n)
|
||||
}
|
||||
}
|
||||
zoneWidth = []cldrtree.Option{length, cldrtree.SharedType()}
|
||||
zs = x.IndexWithName("metaZone")
|
||||
for _, z := range ldml.Dates.TimeZoneNames.Metazone {
|
||||
for _, l := range z.Long {
|
||||
x := zs.Index(l, zoneWidth...)
|
||||
set(x, l.Generic, z.Type)
|
||||
set(x, l.Standard, z.Type)
|
||||
set(x, l.Daylight, z.Type)
|
||||
}
|
||||
for _, s := range z.Short {
|
||||
x := zs.Index(s, zoneWidth...)
|
||||
set(x, s.Generic, z.Type)
|
||||
set(x, s.Standard, z.Type)
|
||||
set(x, s.Daylight, z.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
241
vendor/golang.org/x/text/date/gen_test.go
generated
vendored
Normal file
241
vendor/golang.org/x/text/date/gen_test.go
generated
vendored
Normal file
|
@ -0,0 +1,241 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
package date
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/text/internal/cldrtree"
|
||||
"golang.org/x/text/internal/gen"
|
||||
"golang.org/x/text/internal/testtext"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/unicode/cldr"
|
||||
)
|
||||
|
||||
func TestTables(t *testing.T) {
|
||||
testtext.SkipIfNotLong(t)
|
||||
|
||||
r := gen.OpenCLDRCoreZip()
|
||||
defer r.Close()
|
||||
|
||||
d := &cldr.Decoder{}
|
||||
d.SetDirFilter("supplemental", "main")
|
||||
d.SetSectionFilter("dates")
|
||||
data, err := d.DecodeZip(r)
|
||||
if err != nil {
|
||||
t.Fatalf("DecodeZip: %v", err)
|
||||
}
|
||||
|
||||
count := 0
|
||||
for _, lang := range data.Locales() {
|
||||
ldml := data.RawLDML(lang)
|
||||
if ldml.Dates == nil {
|
||||
continue
|
||||
}
|
||||
tag, _ := language.CompactIndex(language.MustParse(lang))
|
||||
|
||||
test := func(want cldrtree.Element, path ...string) {
|
||||
if count > 30 {
|
||||
return
|
||||
}
|
||||
t.Run(lang+"/"+strings.Join(path, "/"), func(t *testing.T) {
|
||||
p := make([]uint16, len(path))
|
||||
for i, s := range path {
|
||||
if v, err := strconv.Atoi(s); err == nil {
|
||||
p[i] = uint16(v)
|
||||
} else if v, ok := enumMap[s]; ok {
|
||||
p[i] = v
|
||||
} else {
|
||||
count++
|
||||
t.Fatalf("Unknown key %q", s)
|
||||
}
|
||||
}
|
||||
wantStr := want.GetCommon().Data()
|
||||
if got := tree.Lookup(tag, p...); got != wantStr {
|
||||
count++
|
||||
t.Errorf("got %q; want %q", got, wantStr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
width := func(s string) string { return "width" + strings.Title(s) }
|
||||
|
||||
if ldml.Dates.Calendars != nil {
|
||||
for _, cal := range ldml.Dates.Calendars.Calendar {
|
||||
if cal.Months != nil {
|
||||
for _, mc := range cal.Months.MonthContext {
|
||||
for _, mw := range mc.MonthWidth {
|
||||
for _, m := range mw.Month {
|
||||
test(m, "calendars", cal.Type, "months", mc.Type, width(mw.Type), m.Yeartype+m.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.MonthPatterns != nil {
|
||||
for _, mc := range cal.MonthPatterns.MonthPatternContext {
|
||||
for _, mw := range mc.MonthPatternWidth {
|
||||
for _, m := range mw.MonthPattern {
|
||||
test(m, "calendars", cal.Type, "monthPatterns", mc.Type, width(mw.Type))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.CyclicNameSets != nil {
|
||||
for _, cns := range cal.CyclicNameSets.CyclicNameSet {
|
||||
for _, cc := range cns.CyclicNameContext {
|
||||
for _, cw := range cc.CyclicNameWidth {
|
||||
for _, c := range cw.CyclicName {
|
||||
test(c, "calendars", cal.Type, "cyclicNameSets", cns.Type+"CycleType", cc.Type, width(cw.Type), c.Type)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.Days != nil {
|
||||
for _, dc := range cal.Days.DayContext {
|
||||
for _, dw := range dc.DayWidth {
|
||||
for _, d := range dw.Day {
|
||||
test(d, "calendars", cal.Type, "days", dc.Type, width(dw.Type), d.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.Quarters != nil {
|
||||
for _, qc := range cal.Quarters.QuarterContext {
|
||||
for _, qw := range qc.QuarterWidth {
|
||||
for _, q := range qw.Quarter {
|
||||
test(q, "calendars", cal.Type, "quarters", qc.Type, width(qw.Type), q.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.DayPeriods != nil {
|
||||
for _, dc := range cal.DayPeriods.DayPeriodContext {
|
||||
for _, dw := range dc.DayPeriodWidth {
|
||||
for _, d := range dw.DayPeriod {
|
||||
test(d, "calendars", cal.Type, "dayPeriods", dc.Type, width(dw.Type), d.Type, d.Alt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.Eras != nil {
|
||||
if cal.Eras.EraNames != nil {
|
||||
for _, e := range cal.Eras.EraNames.Era {
|
||||
test(e, "calendars", cal.Type, "eras", "widthWide", e.Alt, e.Type)
|
||||
}
|
||||
}
|
||||
if cal.Eras.EraAbbr != nil {
|
||||
for _, e := range cal.Eras.EraAbbr.Era {
|
||||
test(e, "calendars", cal.Type, "eras", "widthAbbreviated", e.Alt, e.Type)
|
||||
}
|
||||
}
|
||||
if cal.Eras.EraNarrow != nil {
|
||||
for _, e := range cal.Eras.EraNarrow.Era {
|
||||
test(e, "calendars", cal.Type, "eras", "widthNarrow", e.Alt, e.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.DateFormats != nil {
|
||||
for _, dfl := range cal.DateFormats.DateFormatLength {
|
||||
for _, df := range dfl.DateFormat {
|
||||
for _, p := range df.Pattern {
|
||||
test(p, "calendars", cal.Type, "dateFormats", dfl.Type, p.Alt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.TimeFormats != nil {
|
||||
for _, tfl := range cal.TimeFormats.TimeFormatLength {
|
||||
for _, tf := range tfl.TimeFormat {
|
||||
for _, p := range tf.Pattern {
|
||||
test(p, "calendars", cal.Type, "timeFormats", tfl.Type, p.Alt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if cal.DateTimeFormats != nil {
|
||||
for _, dtfl := range cal.DateTimeFormats.DateTimeFormatLength {
|
||||
for _, dtf := range dtfl.DateTimeFormat {
|
||||
for _, p := range dtf.Pattern {
|
||||
test(p, "calendars", cal.Type, "dateTimeFormats", dtfl.Type, p.Alt)
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:
|
||||
// - appendItems
|
||||
// - intervalFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: this is a lot of data and is probably relatively little used.
|
||||
// Store this somewhere else.
|
||||
if ldml.Dates.Fields != nil {
|
||||
for _, f := range ldml.Dates.Fields.Field {
|
||||
field := f.Type + "Field"
|
||||
for _, d := range f.DisplayName {
|
||||
test(d, "fields", field, "displayName", d.Alt)
|
||||
}
|
||||
for _, r := range f.Relative {
|
||||
i, _ := strconv.Atoi(r.Type)
|
||||
v := []string{"before2", "before1", "current", "after1", "after2", "after3"}[i+2]
|
||||
test(r, "fields", field, "relative", v)
|
||||
}
|
||||
for _, rt := range f.RelativeTime {
|
||||
for _, p := range rt.RelativeTimePattern {
|
||||
test(p, "fields", field, "relativeTime", rt.Type, p.Count)
|
||||
}
|
||||
}
|
||||
for _, rp := range f.RelativePeriod {
|
||||
test(rp, "fields", field, "relativePeriod", rp.Alt)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ldml.Dates.TimeZoneNames != nil {
|
||||
for _, h := range ldml.Dates.TimeZoneNames.HourFormat {
|
||||
test(h, "timeZoneNames", "zoneFormat", h.Element())
|
||||
}
|
||||
for _, g := range ldml.Dates.TimeZoneNames.GmtFormat {
|
||||
test(g, "timeZoneNames", "zoneFormat", g.Element())
|
||||
}
|
||||
for _, g := range ldml.Dates.TimeZoneNames.GmtZeroFormat {
|
||||
test(g, "timeZoneNames", "zoneFormat", g.Element())
|
||||
}
|
||||
for _, r := range ldml.Dates.TimeZoneNames.RegionFormat {
|
||||
s := r.Type
|
||||
if s == "" {
|
||||
s = "generic"
|
||||
}
|
||||
test(r, "timeZoneNames", "regionFormat", s+"Time")
|
||||
}
|
||||
|
||||
testZone := func(zoneType, zoneWidth, zone string, a ...[]*cldr.Common) {
|
||||
for _, e := range a {
|
||||
for _, n := range e {
|
||||
test(n, "timeZoneNames", zoneType, zoneWidth, n.Element()+"Time", zone)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, z := range ldml.Dates.TimeZoneNames.Zone {
|
||||
for _, l := range z.Long {
|
||||
testZone("zone", l.Element(), z.Type, l.Generic, l.Standard, l.Daylight)
|
||||
}
|
||||
for _, l := range z.Short {
|
||||
testZone("zone", l.Element(), z.Type, l.Generic, l.Standard, l.Daylight)
|
||||
}
|
||||
}
|
||||
for _, z := range ldml.Dates.TimeZoneNames.Metazone {
|
||||
for _, l := range z.Long {
|
||||
testZone("metaZone", l.Element(), z.Type, l.Generic, l.Standard, l.Daylight)
|
||||
}
|
||||
for _, l := range z.Short {
|
||||
testZone("metaZone", l.Element(), z.Type, l.Generic, l.Standard, l.Daylight)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64522
vendor/golang.org/x/text/date/tables.go
generated
vendored
Normal file
64522
vendor/golang.org/x/text/date/tables.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue