OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-playground / locales / to / to.go
1 package to
2
3 import (
4         "math"
5         "strconv"
6         "time"
7
8         "github.com/go-playground/locales"
9         "github.com/go-playground/locales/currency"
10 )
11
12 type to struct {
13         locale                 string
14         pluralsCardinal        []locales.PluralRule
15         pluralsOrdinal         []locales.PluralRule
16         pluralsRange           []locales.PluralRule
17         decimal                string
18         group                  string
19         minus                  string
20         percent                string
21         perMille               string
22         timeSeparator          string
23         inifinity              string
24         currencies             []string // idx = enum of currency code
25         currencyPositivePrefix string
26         currencyNegativePrefix string
27         monthsAbbreviated      []string
28         monthsNarrow           []string
29         monthsWide             []string
30         daysAbbreviated        []string
31         daysNarrow             []string
32         daysShort              []string
33         daysWide               []string
34         periodsAbbreviated     []string
35         periodsNarrow          []string
36         periodsShort           []string
37         periodsWide            []string
38         erasAbbreviated        []string
39         erasNarrow             []string
40         erasWide               []string
41         timezones              map[string]string
42 }
43
44 // New returns a new instance of translator for the 'to' locale
45 func New() locales.Translator {
46         return &to{
47                 locale:                 "to",
48                 pluralsCardinal:        []locales.PluralRule{6},
49                 pluralsOrdinal:         nil,
50                 pluralsRange:           nil,
51                 decimal:                ".",
52                 group:                  ",",
53                 minus:                  "-",
54                 percent:                "%",
55                 perMille:               "‰",
56                 timeSeparator:          ":",
57                 inifinity:              "∞",
58                 currencies:             []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "₾", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "T$", "TPE", "TRL", "TRY", "TTD", "$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59                 currencyPositivePrefix: " ",
60                 currencyNegativePrefix: " ",
61                 monthsAbbreviated:      []string{"", "Sān", "Fēp", "Maʻa", "ʻEpe", "Mē", "Sun", "Siu", "ʻAok", "Sep", "ʻOka", "Nōv", "Tīs"},
62                 monthsNarrow:           []string{"", "S", "F", "M", "E", "M", "S", "S", "A", "S", "O", "N", "T"},
63                 monthsWide:             []string{"", "Sānuali", "Fēpueli", "Maʻasi", "ʻEpeleli", "Mē", "Sune", "Siulai", "ʻAokosi", "Sepitema", "ʻOkatopa", "Nōvema", "Tīsema"},
64                 daysAbbreviated:        []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"},
65                 daysNarrow:             []string{"S", "M", "T", "P", "T", "F", "T"},
66                 daysShort:              []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"},
67                 daysWide:               []string{"Sāpate", "Mōnite", "Tūsite", "Pulelulu", "Tuʻapulelulu", "Falaite", "Tokonaki"},
68                 periodsAbbreviated:     []string{"AM", "PM"},
69                 periodsNarrow:          []string{"AM", "PM"},
70                 periodsWide:            []string{"hengihengi", "efiafi"},
71                 erasAbbreviated:        []string{"KM", "TS"},
72                 erasNarrow:             []string{"", ""},
73                 erasWide:               []string{"ki muʻa", "taʻu ʻo Sīsū"},
74                 timezones:              map[string]string{"GFT": "houa fakakuiana-fakafalanisē", "PDT": "houa fakaʻamelika-tokelau pasifika taimi liliu", "BOT": "houa fakapolīvia", "CDT": "houa fakaʻamelika-tokelau loto taimi liliu", "MEZ": "houa fakaʻeulope-loto taimi totonu", "TMST": "houa fakatūkimenisitani taimi liliu", "OEZ": "houa fakaʻeulope-hahake taimi totonu", "WAT": "houa fakaʻafelika-hihifo taimi totonu", "GYT": "houa fakakuiana", "GMT": "houa fakakiliniuisi mālie", "MYT": "houa fakamaleisia", "HADT": "houa fakahauaʻi taimi liliu", "HENOMX": "houa fakamekisikou-tokelauhihifo taimi liliu", "AST": "houa fakaʻamelika-tokelau ʻatalanitiki taimi totonu", "COT": "houa fakakolomipia taimi totonu", "HKT": "houa fakahongi-kongi taimi totonu", "HECU": "houa fakakiupa taimi liliu", "HEPM": "houa fakasā-piea-mo-mikeloni taimi liliu", "MST": "houa fakamakau taimi totonu", "HAST": "houa fakahauaʻi taimi totonu", "TMT": "houa fakatūkimenisitani taimi totonu", "LHDT": "houa fakamotuʻeikihoue taimi liliu", "WEZ": "houa fakaʻeulope-hihifo taimi totonu", "NZDT": "houa fakanuʻusila taimi liliu", "EST": "houa fakaʻamelika-tokelau hahake taimi totonu", "CAT": "houa fakaʻafelika-loto", "SGT": "houa fakasingapoa", "HEPMX": "houa fakamekisikou-pasifika taimi liliu", "CHAST": "houa fakasatihami taimi totonu", "AEST": "houa fakaʻaositelēlia-hahake taimi totonu", "ART": "houa fakaʻasenitina taimi totonu", "HEEG": "houa fakafonuamata-hahake taimi liliu", "CLT": "houa fakasili taimi totonu", "ACDT": "houa fakaʻaositelēlia-loto taimi liliu", "HAT": "houa fakafonuaʻilofoʻou taimi liliu", "HKST": "houa fakahongi-kongi taimi liliu", "AKDT": "houa fakaʻalasika taimi liliu", "ACWDT": "houa fakaʻaositelēlia-loto-hihifo taimi liliu", "NZST": "houa fakanuʻusila taimi totonu", "ARST": "houa fakaʻasenitina taimi liliu", "HNOG": "houa fakafonuamata-hihifo taimi totonu", "HNEG": "houa fakafonuamata-hahake taimi totonu", "MDT": "houa fakamakau taimi liliu", "VET": "houa fakavenesuela", "ADT": "houa fakaʻamelika-tokelau ʻatalanitiki taimi liliu", "WAST": "houa fakaʻafelika-hihifo taimi liliu", "OESZ": "houa fakaʻeulope-hahake taimi liliu", "AEDT": "houa fakaʻaositelēlia-hahake taimi liliu", "SAST": "houa fakaʻafelika-tonga", "AWDT": "houa fakaʻaositelēlia-hihifo taimi liliu", "UYT": "houa fakaʻulukuai taimi totonu", "WIT": "houa fakaʻinitonisia-hahake", "MESZ": "houa fakaʻeulope-loto taimi liliu", "JDT": "houa fakasiapani taimi liliu", "COST": "houa fakakolomipia taimi liliu", "EDT": "houa fakaʻamelika-tokelau hahake taimi liliu", "ACST": "houa fakaʻaositelēlia-loto taimi totonu", "WESZ": "houa fakaʻeulope-hihifo taimi liliu", "CLST": "houa fakasili taimi liliu", "JST": "houa fakasiapani taimi totonu", "WART": "houa fakaʻasenitina-hihifo taimi totonu", "ChST": "houa fakakamolo", "PST": "houa fakaʻamelika-tokelau pasifika taimi totonu", "WITA": "houa fakaʻinitonisia-loto", "LHST": "houa fakamotuʻeikihoue taimi totonu", "WARST": "houa fakaʻasenitina-hihifo taimi liliu", "HNCU": "houa fakakiupa taimi totonu", "BT": "houa fakapūtani", "CST": "houa fakaʻamelika-tokelau loto taimi totonu", "IST": "houa fakaʻinitia", "ECT": "houa fakaʻekuetoa", "WIB": "houa fakaʻinitonisia-hihifo", "HNPM": "houa fakasā-piea-mo-mikeloni taimi totonu", "SRT": "houa fakasuliname", "UYST": "houa fakaʻulukuai taimi liliu", "HNNOMX": "houa fakamekisikou-tokelauhihifo taimi totonu", "HEOG": "houa fakafonuamata-hihifo taimi liliu", "AKST": "houa fakaʻalasika taimi totonu", "HNPMX": "houa fakamekisikou-pasifika taimi totonu", "CHADT": "houa fakasatihami taimi liliu", "AWST": "houa fakaʻaositelēlia-hihifo taimi totonu", "∅∅∅": "houa fakaʻakelī taimi liliu", "ACWST": "houa fakaʻaositelēlia-loto-hihifo taimi totonu", "EAT": "houa fakaʻafelika-hahake", "HNT": "houa fakafonuaʻilofoʻou taimi totonu"},
75         }
76 }
77
78 // Locale returns the current translators string locale
79 func (to *to) Locale() string {
80         return to.locale
81 }
82
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'to'
84 func (to *to) PluralsCardinal() []locales.PluralRule {
85         return to.pluralsCardinal
86 }
87
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'to'
89 func (to *to) PluralsOrdinal() []locales.PluralRule {
90         return to.pluralsOrdinal
91 }
92
93 // PluralsRange returns the list of range plural rules associated with 'to'
94 func (to *to) PluralsRange() []locales.PluralRule {
95         return to.pluralsRange
96 }
97
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'to'
99 func (to *to) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100         return locales.PluralRuleOther
101 }
102
103 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'to'
104 func (to *to) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105         return locales.PluralRuleUnknown
106 }
107
108 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'to'
109 func (to *to) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
110         return locales.PluralRuleUnknown
111 }
112
113 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
114 func (to *to) MonthAbbreviated(month time.Month) string {
115         return to.monthsAbbreviated[month]
116 }
117
118 // MonthsAbbreviated returns the locales abbreviated months
119 func (to *to) MonthsAbbreviated() []string {
120         return to.monthsAbbreviated[1:]
121 }
122
123 // MonthNarrow returns the locales narrow month given the 'month' provided
124 func (to *to) MonthNarrow(month time.Month) string {
125         return to.monthsNarrow[month]
126 }
127
128 // MonthsNarrow returns the locales narrow months
129 func (to *to) MonthsNarrow() []string {
130         return to.monthsNarrow[1:]
131 }
132
133 // MonthWide returns the locales wide month given the 'month' provided
134 func (to *to) MonthWide(month time.Month) string {
135         return to.monthsWide[month]
136 }
137
138 // MonthsWide returns the locales wide months
139 func (to *to) MonthsWide() []string {
140         return to.monthsWide[1:]
141 }
142
143 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
144 func (to *to) WeekdayAbbreviated(weekday time.Weekday) string {
145         return to.daysAbbreviated[weekday]
146 }
147
148 // WeekdaysAbbreviated returns the locales abbreviated weekdays
149 func (to *to) WeekdaysAbbreviated() []string {
150         return to.daysAbbreviated
151 }
152
153 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
154 func (to *to) WeekdayNarrow(weekday time.Weekday) string {
155         return to.daysNarrow[weekday]
156 }
157
158 // WeekdaysNarrow returns the locales narrow weekdays
159 func (to *to) WeekdaysNarrow() []string {
160         return to.daysNarrow
161 }
162
163 // WeekdayShort returns the locales short weekday given the 'weekday' provided
164 func (to *to) WeekdayShort(weekday time.Weekday) string {
165         return to.daysShort[weekday]
166 }
167
168 // WeekdaysShort returns the locales short weekdays
169 func (to *to) WeekdaysShort() []string {
170         return to.daysShort
171 }
172
173 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
174 func (to *to) WeekdayWide(weekday time.Weekday) string {
175         return to.daysWide[weekday]
176 }
177
178 // WeekdaysWide returns the locales wide weekdays
179 func (to *to) WeekdaysWide() []string {
180         return to.daysWide
181 }
182
183 // Decimal returns the decimal point of number
184 func (to *to) Decimal() string {
185         return to.decimal
186 }
187
188 // Group returns the group of number
189 func (to *to) Group() string {
190         return to.group
191 }
192
193 // Group returns the minus sign of number
194 func (to *to) Minus() string {
195         return to.minus
196 }
197
198 // FmtNumber returns 'num' with digits/precision of 'v' for 'to' and handles both Whole and Real numbers based on 'v'
199 func (to *to) FmtNumber(num float64, v uint64) string {
200
201         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202         l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
203         count := 0
204         inWhole := v == 0
205         b := make([]byte, 0, l)
206
207         for i := len(s) - 1; i >= 0; i-- {
208
209                 if s[i] == '.' {
210                         b = append(b, to.decimal[0])
211                         inWhole = true
212                         continue
213                 }
214
215                 if inWhole {
216                         if count == 3 {
217                                 b = append(b, to.group[0])
218                                 count = 1
219                         } else {
220                                 count++
221                         }
222                 }
223
224                 b = append(b, s[i])
225         }
226
227         if num < 0 {
228                 b = append(b, to.minus[0])
229         }
230
231         // reverse
232         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
233                 b[i], b[j] = b[j], b[i]
234         }
235
236         return string(b)
237 }
238
239 // FmtPercent returns 'num' with digits/precision of 'v' for 'to' and handles both Whole and Real numbers based on 'v'
240 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
241 func (to *to) FmtPercent(num float64, v uint64) string {
242         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
243         l := len(s) + 3
244         b := make([]byte, 0, l)
245
246         for i := len(s) - 1; i >= 0; i-- {
247
248                 if s[i] == '.' {
249                         b = append(b, to.decimal[0])
250                         continue
251                 }
252
253                 b = append(b, s[i])
254         }
255
256         if num < 0 {
257                 b = append(b, to.minus[0])
258         }
259
260         // reverse
261         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
262                 b[i], b[j] = b[j], b[i]
263         }
264
265         b = append(b, to.percent...)
266
267         return string(b)
268 }
269
270 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'to'
271 func (to *to) FmtCurrency(num float64, v uint64, currency currency.Type) string {
272
273         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274         symbol := to.currencies[currency]
275         l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
276         count := 0
277         inWhole := v == 0
278         b := make([]byte, 0, l)
279
280         for i := len(s) - 1; i >= 0; i-- {
281
282                 if s[i] == '.' {
283                         b = append(b, to.decimal[0])
284                         inWhole = true
285                         continue
286                 }
287
288                 if inWhole {
289                         if count == 3 {
290                                 b = append(b, to.group[0])
291                                 count = 1
292                         } else {
293                                 count++
294                         }
295                 }
296
297                 b = append(b, s[i])
298         }
299
300         for j := len(symbol) - 1; j >= 0; j-- {
301                 b = append(b, symbol[j])
302         }
303
304         for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- {
305                 b = append(b, to.currencyPositivePrefix[j])
306         }
307
308         if num < 0 {
309                 b = append(b, to.minus[0])
310         }
311
312         // reverse
313         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
314                 b[i], b[j] = b[j], b[i]
315         }
316
317         if int(v) < 2 {
318
319                 if v == 0 {
320                         b = append(b, to.decimal...)
321                 }
322
323                 for i := 0; i < 2-int(v); i++ {
324                         b = append(b, '0')
325                 }
326         }
327
328         return string(b)
329 }
330
331 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'to'
332 // in accounting notation.
333 func (to *to) FmtAccounting(num float64, v uint64, currency currency.Type) string {
334
335         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
336         symbol := to.currencies[currency]
337         l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
338         count := 0
339         inWhole := v == 0
340         b := make([]byte, 0, l)
341
342         for i := len(s) - 1; i >= 0; i-- {
343
344                 if s[i] == '.' {
345                         b = append(b, to.decimal[0])
346                         inWhole = true
347                         continue
348                 }
349
350                 if inWhole {
351                         if count == 3 {
352                                 b = append(b, to.group[0])
353                                 count = 1
354                         } else {
355                                 count++
356                         }
357                 }
358
359                 b = append(b, s[i])
360         }
361
362         if num < 0 {
363
364                 for j := len(symbol) - 1; j >= 0; j-- {
365                         b = append(b, symbol[j])
366                 }
367
368                 for j := len(to.currencyNegativePrefix) - 1; j >= 0; j-- {
369                         b = append(b, to.currencyNegativePrefix[j])
370                 }
371
372                 b = append(b, to.minus[0])
373
374         } else {
375
376                 for j := len(symbol) - 1; j >= 0; j-- {
377                         b = append(b, symbol[j])
378                 }
379
380                 for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- {
381                         b = append(b, to.currencyPositivePrefix[j])
382                 }
383
384         }
385
386         // reverse
387         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
388                 b[i], b[j] = b[j], b[i]
389         }
390
391         if int(v) < 2 {
392
393                 if v == 0 {
394                         b = append(b, to.decimal...)
395                 }
396
397                 for i := 0; i < 2-int(v); i++ {
398                         b = append(b, '0')
399                 }
400         }
401
402         return string(b)
403 }
404
405 // FmtDateShort returns the short date representation of 't' for 'to'
406 func (to *to) FmtDateShort(t time.Time) string {
407
408         b := make([]byte, 0, 32)
409
410         b = strconv.AppendInt(b, int64(t.Day()), 10)
411         b = append(b, []byte{0x2f}...)
412         b = strconv.AppendInt(b, int64(t.Month()), 10)
413         b = append(b, []byte{0x2f}...)
414
415         if t.Year() > 9 {
416                 b = append(b, strconv.Itoa(t.Year())[2:]...)
417         } else {
418                 b = append(b, strconv.Itoa(t.Year())[1:]...)
419         }
420
421         return string(b)
422 }
423
424 // FmtDateMedium returns the medium date representation of 't' for 'to'
425 func (to *to) FmtDateMedium(t time.Time) string {
426
427         b := make([]byte, 0, 32)
428
429         b = strconv.AppendInt(b, int64(t.Day()), 10)
430         b = append(b, []byte{0x20}...)
431         b = append(b, to.monthsAbbreviated[t.Month()]...)
432         b = append(b, []byte{0x20}...)
433
434         if t.Year() > 0 {
435                 b = strconv.AppendInt(b, int64(t.Year()), 10)
436         } else {
437                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
438         }
439
440         return string(b)
441 }
442
443 // FmtDateLong returns the long date representation of 't' for 'to'
444 func (to *to) FmtDateLong(t time.Time) string {
445
446         b := make([]byte, 0, 32)
447
448         b = strconv.AppendInt(b, int64(t.Day()), 10)
449         b = append(b, []byte{0x20}...)
450         b = append(b, to.monthsWide[t.Month()]...)
451         b = append(b, []byte{0x20}...)
452
453         if t.Year() > 0 {
454                 b = strconv.AppendInt(b, int64(t.Year()), 10)
455         } else {
456                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
457         }
458
459         return string(b)
460 }
461
462 // FmtDateFull returns the full date representation of 't' for 'to'
463 func (to *to) FmtDateFull(t time.Time) string {
464
465         b := make([]byte, 0, 32)
466
467         b = append(b, to.daysWide[t.Weekday()]...)
468         b = append(b, []byte{0x20}...)
469         b = strconv.AppendInt(b, int64(t.Day()), 10)
470         b = append(b, []byte{0x20}...)
471         b = append(b, to.monthsWide[t.Month()]...)
472         b = append(b, []byte{0x20}...)
473
474         if t.Year() > 0 {
475                 b = strconv.AppendInt(b, int64(t.Year()), 10)
476         } else {
477                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
478         }
479
480         return string(b)
481 }
482
483 // FmtTimeShort returns the short time representation of 't' for 'to'
484 func (to *to) FmtTimeShort(t time.Time) string {
485
486         b := make([]byte, 0, 32)
487
488         h := t.Hour()
489
490         if h > 12 {
491                 h -= 12
492         }
493
494         b = strconv.AppendInt(b, int64(h), 10)
495         b = append(b, to.timeSeparator...)
496
497         if t.Minute() < 10 {
498                 b = append(b, '0')
499         }
500
501         b = strconv.AppendInt(b, int64(t.Minute()), 10)
502         b = append(b, []byte{0x20}...)
503
504         if t.Hour() < 12 {
505                 b = append(b, to.periodsAbbreviated[0]...)
506         } else {
507                 b = append(b, to.periodsAbbreviated[1]...)
508         }
509
510         return string(b)
511 }
512
513 // FmtTimeMedium returns the medium time representation of 't' for 'to'
514 func (to *to) FmtTimeMedium(t time.Time) string {
515
516         b := make([]byte, 0, 32)
517
518         h := t.Hour()
519
520         if h > 12 {
521                 h -= 12
522         }
523
524         b = strconv.AppendInt(b, int64(h), 10)
525         b = append(b, to.timeSeparator...)
526
527         if t.Minute() < 10 {
528                 b = append(b, '0')
529         }
530
531         b = strconv.AppendInt(b, int64(t.Minute()), 10)
532         b = append(b, to.timeSeparator...)
533
534         if t.Second() < 10 {
535                 b = append(b, '0')
536         }
537
538         b = strconv.AppendInt(b, int64(t.Second()), 10)
539         b = append(b, []byte{0x20}...)
540
541         if t.Hour() < 12 {
542                 b = append(b, to.periodsAbbreviated[0]...)
543         } else {
544                 b = append(b, to.periodsAbbreviated[1]...)
545         }
546
547         return string(b)
548 }
549
550 // FmtTimeLong returns the long time representation of 't' for 'to'
551 func (to *to) FmtTimeLong(t time.Time) string {
552
553         b := make([]byte, 0, 32)
554
555         h := t.Hour()
556
557         if h > 12 {
558                 h -= 12
559         }
560
561         b = strconv.AppendInt(b, int64(h), 10)
562         b = append(b, to.timeSeparator...)
563
564         if t.Minute() < 10 {
565                 b = append(b, '0')
566         }
567
568         b = strconv.AppendInt(b, int64(t.Minute()), 10)
569         b = append(b, to.timeSeparator...)
570
571         if t.Second() < 10 {
572                 b = append(b, '0')
573         }
574
575         b = strconv.AppendInt(b, int64(t.Second()), 10)
576         b = append(b, []byte{0x20}...)
577
578         if t.Hour() < 12 {
579                 b = append(b, to.periodsAbbreviated[0]...)
580         } else {
581                 b = append(b, to.periodsAbbreviated[1]...)
582         }
583
584         b = append(b, []byte{0x20}...)
585
586         tz, _ := t.Zone()
587         b = append(b, tz...)
588
589         return string(b)
590 }
591
592 // FmtTimeFull returns the full time representation of 't' for 'to'
593 func (to *to) FmtTimeFull(t time.Time) string {
594
595         b := make([]byte, 0, 32)
596
597         h := t.Hour()
598
599         if h > 12 {
600                 h -= 12
601         }
602
603         b = strconv.AppendInt(b, int64(h), 10)
604         b = append(b, to.timeSeparator...)
605
606         if t.Minute() < 10 {
607                 b = append(b, '0')
608         }
609
610         b = strconv.AppendInt(b, int64(t.Minute()), 10)
611         b = append(b, to.timeSeparator...)
612
613         if t.Second() < 10 {
614                 b = append(b, '0')
615         }
616
617         b = strconv.AppendInt(b, int64(t.Second()), 10)
618         b = append(b, []byte{0x20}...)
619
620         if t.Hour() < 12 {
621                 b = append(b, to.periodsAbbreviated[0]...)
622         } else {
623                 b = append(b, to.periodsAbbreviated[1]...)
624         }
625
626         b = append(b, []byte{0x20}...)
627
628         tz, _ := t.Zone()
629
630         if btz, ok := to.timezones[tz]; ok {
631                 b = append(b, btz...)
632         } else {
633                 b = append(b, tz...)
634         }
635
636         return string(b)
637 }