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