1package te
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/gohugoio/locales"
9	"github.com/gohugoio/locales/currency"
10)
11
12type te 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	currencyNegativePrefix string
26	currencyNegativeSuffix 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 'te' locale
45func New() locales.Translator {
46	return &te{
47		locale:                 "te",
48		pluralsCardinal:        []locales.PluralRule{2, 6},
49		pluralsOrdinal:         []locales.PluralRule{6},
50		pluralsRange:           []locales.PluralRule{2, 6},
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", "A$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "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", "STN", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59		currencyNegativePrefix: "(",
60		currencyNegativeSuffix: ")",
61		monthsAbbreviated:      []string{"", "జన", "ఫిబ్ర", "మార్చి", "ఏప్రి", "మే", "జూన్", "జులై", "ఆగ", "సెప్టెం", "అక్టో", "నవం", "డిసెం"},
62		monthsNarrow:           []string{"", "జ", "ఫి", "మా", "ఏ", "మే", "జూ", "జు", "ఆ", "సె", "అ", "న", "డి"},
63		monthsWide:             []string{"", "జనవరి", "ఫిబ్రవరి", "మార్చి", "ఏప్రిల్", "మే", "జూన్", "జులై", "ఆగస్టు", "సెప్టెంబర్", "అక్టోబర్", "నవంబర్", "డిసెంబర్"},
64		daysAbbreviated:        []string{"ఆది", "సోమ", "మంగళ", "బుధ", "గురు", "శుక్ర", "శని"},
65		daysNarrow:             []string{"ఆ", "సో", "మ", "బు", "గు", "శు", "శ"},
66		daysShort:              []string{"ఆది", "సోమ", "మం", "బుధ", "గురు", "శుక్ర", "శని"},
67		daysWide:               []string{"ఆదివారం", "సోమవారం", "మంగళవారం", "బుధవారం", "గురువారం", "శుక్రవారం", "శనివారం"},
68		periodsAbbreviated:     []string{"AM", "PM"},
69		periodsNarrow:          []string{"ఉ", "సా"},
70		periodsWide:            []string{"AM", "PM"},
71		erasAbbreviated:        []string{"క్రీపూ", "క్రీశ"},
72		erasNarrow:             []string{"", ""},
73		erasWide:               []string{"క్రీస్తు పూర్వం", "క్రీస్తు శకం"},
74		timezones:              map[string]string{"ACDT": "ఆస్ట్రేలియా మధ్యమ పగటి వెలుతురు సమయం", "ACST": "ఆస్ట్రేలియా మధ్యమ ప్రామాణిక సమయం", "ACWDT": "ఆస్ట్రేలియా మధ్యమ పశ్చిమ పగటి వెలుతురు సమయం", "ACWST": "మధ్యమ ఆస్ట్రేలియన్ పశ్చిమ ప్రామాణిక సమయం", "ADT": "అట్లాంటిక్ పగటి వెలుతురు సమయం", "AEDT": "ఆస్ట్రేలియన్ తూర్పు పగటి వెలుతురు సమయం", "AEST": "ఆస్ట్రేలియన్ తూర్పు ప్రామాణిక సమయం", "AKDT": "అలాస్కా పగటి వెలుతురు సమయం", "AKST": "అలాస్కా ప్రామాణిక సమయం", "ARST": "ఆర్జెంటీనా వేసవి సమయం", "ART": "అర్జెంటీనా ప్రామాణిక సమయం", "AST": "అట్లాంటిక్ ప్రామాణిక సమయం", "AWDT": "ఆస్ట్రేలియన్ పశ్చిమ పగటి వెలుతురు సమయం", "AWST": "ఆస్ట్రేలియన్ పశ్చిమ ప్రామాణిక సమయం", "BOT": "బొలీవియా సమయం", "BT": "భూటాన్ సమయం", "CAT": "సెంట్రల్ ఆఫ్రికా సమయం", "CDT": "మధ్యమ పగటి వెలుతురు సమయం", "CHADT": "చాథమ్ పగటి వెలుతురు సమయం", "CHAST": "చాథమ్ ప్రామాణిక సమయం", "CLST": "చిలీ వేసవి సమయం", "CLT": "చిలీ ప్రామాణిక సమయం", "COST": "కొలంబియా వేసవి సమయం", "COT": "కొలంబియా ప్రామాణిక సమయం", "CST": "మధ్యమ ప్రామాణిక సమయం", "ChST": "చామర్రో ప్రామాణిక సమయం", "EAT": "తూర్పు ఆఫ్రికా సమయం", "ECT": "ఈక్వడార్ సమయం", "EDT": "తూర్పు పగటి వెలుతురు సమయం", "EST": "తూర్పు ప్రామాణిక సమయం", "GFT": "ఫ్రెంచ్ గయానా సమయం", "GMT": "గ్రీన్\u200cవిచ్ సగటు సమయం", "GST": "గల్ఫ్ ప్రామాణిక సమయం", "GYT": "గయానా సమయం", "HADT": "హవాయ్-అల్యూషియన్ పగటి వెలుతురు సమయం", "HAST": "హవాయ్-అల్యూషియన్ ప్రామాణిక సమయం", "HAT": "న్యూఫౌండ్\u200cల్యాండ్ పగటి వెలుతురు సమయం", "HECU": "క్యూబా పగటి వెలుతురు సమయం", "HEEG": "తూర్పు గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "HENOMX": "వాయువ్య మెక్సికో పగటి వెలుతురు సమయం", "HEOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "HEPM": "సెయింట్ పియర్ మరియు మిక్వెలాన్ పగటి వెలుతురు సమయం", "HEPMX": "మెక్సికన్ పసిఫిక్ పగటి వెలుతురు సమయం", "HKST": "హాంకాంగ్ వేసవి సమయం", "HKT": "హాంకాంగ్ ప్రామాణిక సమయం", "HNCU": "క్యూబా ప్రామాణిక సమయం", "HNEG": "తూర్పు గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "HNNOMX": "వాయువ్య మెక్సికో ప్రామాణిక సమయం", "HNOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "HNPM": "సెయింట్ పియెర్ మరియు మిక్వెలాన్ ప్రామాణిక సమయం", "HNPMX": "మెక్సికన్ పసిఫిక్ ప్రామాణిక సమయం", "HNT": "న్యూఫౌండ్\u200cల్యాండ్ ప్రామాణిక సమయం", "IST": "భారతదేశ సమయం", "JDT": "జపాన్ పగటి వెలుతురు సమయం", "JST": "జపాన్ ప్రామాణిక సమయం", "LHDT": "లార్డ్ హోవ్ పగటి సమయం", "LHST": "లార్డ్ హోవ్ ప్రామాణిక సమయం", "MDT": "మౌంటెయిన్ పగటి వెలుతురు సమయం", "MESZ": "సెంట్రల్ యూరోపియన్ వేసవి సమయం", "MEZ": "సెంట్రల్ యూరోపియన్ ప్రామాణిక సమయం", "MST": "మౌంటెయిన్ ప్రామాణిక సమయం", "MYT": "మలేషియా సమయం", "NZDT": "న్యూజిల్యాండ్ పగటి వెలుతురు సమయం", "NZST": "న్యూజిల్యాండ్ ప్రామాణిక సమయం", "OESZ": "తూర్పు యూరోపియన్ వేసవి సమయం", "OEZ": "తూర్పు యూరోపియన్ ప్రామాణిక సమయం", "PDT": "పసిఫిక్ పగటి వెలుతురు సమయం", "PST": "పసిఫిక్ ప్రామాణిక సమయం", "SAST": "దక్షిణ ఆఫ్రికా ప్రామాణిక సమయం", "SGT": "సింగపూర్ ప్రామాణిక సమయం", "SRT": "సూరినామ్ సమయం", "TMST": "తుర్క్\u200cమెనిస్తాన్ వేసవి సమయం", "TMT": "తుర్క్\u200cమెనిస్తాన్ ప్రామాణిక సమయం", "UYST": "ఉరుగ్వే వేసవి సమయం", "UYT": "ఉరుగ్వే ప్రామాణిక సమయం", "VET": "వెనిజులా సమయం", "WARST": "పశ్చిమ అర్జెంటీనా వేసవి సమయం", "WART": "పశ్చిమ అర్జెంటీనా ప్రామాణిక సమయం", "WAST": "పశ్చిమ ఆఫ్రికా వేసవి సమయం", "WAT": "పశ్చిమ ఆఫ్రికా ప్రామాణిక సమయం", "WESZ": "పశ్చిమ యూరోపియన్ వేసవి సమయం", "WEZ": "పశ్చిమ యూరోపియన్ ప్రామాణిక సమయం", "WIB": "పశ్చిమ ఇండోనేషియా సమయం", "WIT": "తూర్పు ఇండోనేషియా సమయం", "WITA": "సెంట్రల్ ఇండోనేషియా సమయం", "∅∅∅": "బ్రెజిలియా వేసవి సమయం"},
75	}
76}
77
78// Locale returns the current translators string locale
79func (te *te) Locale() string {
80	return te.locale
81}
82
83// PluralsCardinal returns the list of cardinal plural rules associated with 'te'
84func (te *te) PluralsCardinal() []locales.PluralRule {
85	return te.pluralsCardinal
86}
87
88// PluralsOrdinal returns the list of ordinal plural rules associated with 'te'
89func (te *te) PluralsOrdinal() []locales.PluralRule {
90	return te.pluralsOrdinal
91}
92
93// PluralsRange returns the list of range plural rules associated with 'te'
94func (te *te) PluralsRange() []locales.PluralRule {
95	return te.pluralsRange
96}
97
98// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'te'
99func (te *te) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101	n := math.Abs(num)
102
103	if n == 1 {
104		return locales.PluralRuleOne
105	}
106
107	return locales.PluralRuleOther
108}
109
110// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'te'
111func (te *te) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
112	return locales.PluralRuleOther
113}
114
115// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'te'
116func (te *te) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
117
118	start := te.CardinalPluralRule(num1, v1)
119	end := te.CardinalPluralRule(num2, v2)
120
121	if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
122		return locales.PluralRuleOther
123	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
124		return locales.PluralRuleOne
125	}
126
127	return locales.PluralRuleOther
128
129}
130
131// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
132func (te *te) MonthAbbreviated(month time.Month) string {
133	return te.monthsAbbreviated[month]
134}
135
136// MonthsAbbreviated returns the locales abbreviated months
137func (te *te) MonthsAbbreviated() []string {
138	return te.monthsAbbreviated[1:]
139}
140
141// MonthNarrow returns the locales narrow month given the 'month' provided
142func (te *te) MonthNarrow(month time.Month) string {
143	return te.monthsNarrow[month]
144}
145
146// MonthsNarrow returns the locales narrow months
147func (te *te) MonthsNarrow() []string {
148	return te.monthsNarrow[1:]
149}
150
151// MonthWide returns the locales wide month given the 'month' provided
152func (te *te) MonthWide(month time.Month) string {
153	return te.monthsWide[month]
154}
155
156// MonthsWide returns the locales wide months
157func (te *te) MonthsWide() []string {
158	return te.monthsWide[1:]
159}
160
161// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
162func (te *te) WeekdayAbbreviated(weekday time.Weekday) string {
163	return te.daysAbbreviated[weekday]
164}
165
166// WeekdaysAbbreviated returns the locales abbreviated weekdays
167func (te *te) WeekdaysAbbreviated() []string {
168	return te.daysAbbreviated
169}
170
171// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
172func (te *te) WeekdayNarrow(weekday time.Weekday) string {
173	return te.daysNarrow[weekday]
174}
175
176// WeekdaysNarrow returns the locales narrow weekdays
177func (te *te) WeekdaysNarrow() []string {
178	return te.daysNarrow
179}
180
181// WeekdayShort returns the locales short weekday given the 'weekday' provided
182func (te *te) WeekdayShort(weekday time.Weekday) string {
183	return te.daysShort[weekday]
184}
185
186// WeekdaysShort returns the locales short weekdays
187func (te *te) WeekdaysShort() []string {
188	return te.daysShort
189}
190
191// WeekdayWide returns the locales wide weekday given the 'weekday' provided
192func (te *te) WeekdayWide(weekday time.Weekday) string {
193	return te.daysWide[weekday]
194}
195
196// WeekdaysWide returns the locales wide weekdays
197func (te *te) WeekdaysWide() []string {
198	return te.daysWide
199}
200
201// Decimal returns the decimal point of number
202func (te *te) Decimal() string {
203	return te.decimal
204}
205
206// Group returns the group of number
207func (te *te) Group() string {
208	return te.group
209}
210
211// Group returns the minus sign of number
212func (te *te) Minus() string {
213	return te.minus
214}
215
216// FmtNumber returns 'num' with digits/precision of 'v' for 'te' and handles both Whole and Real numbers based on 'v'
217func (te *te) FmtNumber(num float64, v uint64) string {
218
219	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
220	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
221	count := 0
222	inWhole := v == 0
223	inSecondary := false
224	groupThreshold := 3
225
226	b := make([]byte, 0, l)
227
228	for i := len(s) - 1; i >= 0; i-- {
229
230		if s[i] == '.' {
231			b = append(b, te.decimal[0])
232			inWhole = true
233			continue
234		}
235
236		if inWhole {
237
238			if count == groupThreshold {
239				b = append(b, te.group[0])
240				count = 1
241
242				if !inSecondary {
243					inSecondary = true
244					groupThreshold = 2
245				}
246			} else {
247				count++
248			}
249		}
250
251		b = append(b, s[i])
252	}
253
254	if num < 0 {
255		b = append(b, te.minus[0])
256	}
257
258	// reverse
259	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
260		b[i], b[j] = b[j], b[i]
261	}
262
263	return string(b)
264}
265
266// FmtPercent returns 'num' with digits/precision of 'v' for 'te' and handles both Whole and Real numbers based on 'v'
267// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
268func (te *te) FmtPercent(num float64, v uint64) string {
269	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270	l := len(s) + 3
271	b := make([]byte, 0, l)
272
273	for i := len(s) - 1; i >= 0; i-- {
274
275		if s[i] == '.' {
276			b = append(b, te.decimal[0])
277			continue
278		}
279
280		b = append(b, s[i])
281	}
282
283	if num < 0 {
284		b = append(b, te.minus[0])
285	}
286
287	// reverse
288	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
289		b[i], b[j] = b[j], b[i]
290	}
291
292	b = append(b, te.percent...)
293
294	return string(b)
295}
296
297// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'te'
298func (te *te) FmtCurrency(num float64, v uint64, currency currency.Type) string {
299
300	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
301	symbol := te.currencies[currency]
302	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
303	count := 0
304	inWhole := v == 0
305	b := make([]byte, 0, l)
306
307	for i := len(s) - 1; i >= 0; i-- {
308
309		if s[i] == '.' {
310			b = append(b, te.decimal[0])
311			inWhole = true
312			continue
313		}
314
315		if inWhole {
316			if count == 3 {
317				b = append(b, te.group[0])
318				count = 1
319			} else {
320				count++
321			}
322		}
323
324		b = append(b, s[i])
325	}
326
327	for j := len(symbol) - 1; j >= 0; j-- {
328		b = append(b, symbol[j])
329	}
330
331	if num < 0 {
332		b = append(b, te.minus[0])
333	}
334
335	// reverse
336	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
337		b[i], b[j] = b[j], b[i]
338	}
339
340	if int(v) < 2 {
341
342		if v == 0 {
343			b = append(b, te.decimal...)
344		}
345
346		for i := 0; i < 2-int(v); i++ {
347			b = append(b, '0')
348		}
349	}
350
351	return string(b)
352}
353
354// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'te'
355// in accounting notation.
356func (te *te) FmtAccounting(num float64, v uint64, currency currency.Type) string {
357
358	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
359	symbol := te.currencies[currency]
360	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
361	count := 0
362	inWhole := v == 0
363	b := make([]byte, 0, l)
364
365	for i := len(s) - 1; i >= 0; i-- {
366
367		if s[i] == '.' {
368			b = append(b, te.decimal[0])
369			inWhole = true
370			continue
371		}
372
373		if inWhole {
374			if count == 3 {
375				b = append(b, te.group[0])
376				count = 1
377			} else {
378				count++
379			}
380		}
381
382		b = append(b, s[i])
383	}
384
385	if num < 0 {
386
387		for j := len(symbol) - 1; j >= 0; j-- {
388			b = append(b, symbol[j])
389		}
390
391		b = append(b, te.currencyNegativePrefix[0])
392
393	} else {
394
395		for j := len(symbol) - 1; j >= 0; j-- {
396			b = append(b, symbol[j])
397		}
398
399	}
400
401	// reverse
402	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
403		b[i], b[j] = b[j], b[i]
404	}
405
406	if int(v) < 2 {
407
408		if v == 0 {
409			b = append(b, te.decimal...)
410		}
411
412		for i := 0; i < 2-int(v); i++ {
413			b = append(b, '0')
414		}
415	}
416
417	if num < 0 {
418		b = append(b, te.currencyNegativeSuffix...)
419	}
420
421	return string(b)
422}
423
424// FmtDateShort returns the short date representation of 't' for 'te'
425func (te *te) FmtDateShort(t time.Time) string {
426
427	b := make([]byte, 0, 32)
428
429	if t.Day() < 10 {
430		b = append(b, '0')
431	}
432
433	b = strconv.AppendInt(b, int64(t.Day()), 10)
434	b = append(b, []byte{0x2d}...)
435
436	if t.Month() < 10 {
437		b = append(b, '0')
438	}
439
440	b = strconv.AppendInt(b, int64(t.Month()), 10)
441
442	b = append(b, []byte{0x2d}...)
443
444	if t.Year() > 9 {
445		b = append(b, strconv.Itoa(t.Year())[2:]...)
446	} else {
447		b = append(b, strconv.Itoa(t.Year())[1:]...)
448	}
449
450	return string(b)
451}
452
453// FmtDateMedium returns the medium date representation of 't' for 'te'
454func (te *te) FmtDateMedium(t time.Time) string {
455
456	b := make([]byte, 0, 32)
457
458	b = strconv.AppendInt(b, int64(t.Day()), 10)
459	b = append(b, []byte{0x20}...)
460	b = append(b, te.monthsAbbreviated[t.Month()]...)
461	b = append(b, []byte{0x2c, 0x20}...)
462
463	if t.Year() > 0 {
464		b = strconv.AppendInt(b, int64(t.Year()), 10)
465	} else {
466		b = strconv.AppendInt(b, int64(-t.Year()), 10)
467	}
468
469	return string(b)
470}
471
472// FmtDateLong returns the long date representation of 't' for 'te'
473func (te *te) FmtDateLong(t time.Time) string {
474
475	b := make([]byte, 0, 32)
476
477	b = strconv.AppendInt(b, int64(t.Day()), 10)
478	b = append(b, []byte{0x20}...)
479	b = append(b, te.monthsWide[t.Month()]...)
480	b = append(b, []byte{0x2c, 0x20}...)
481
482	if t.Year() > 0 {
483		b = strconv.AppendInt(b, int64(t.Year()), 10)
484	} else {
485		b = strconv.AppendInt(b, int64(-t.Year()), 10)
486	}
487
488	return string(b)
489}
490
491// FmtDateFull returns the full date representation of 't' for 'te'
492func (te *te) FmtDateFull(t time.Time) string {
493
494	b := make([]byte, 0, 32)
495
496	b = strconv.AppendInt(b, int64(t.Day()), 10)
497	b = append(b, []byte{0x2c, 0x20}...)
498	b = append(b, te.monthsWide[t.Month()]...)
499	b = append(b, []byte{0x20}...)
500
501	if t.Year() > 0 {
502		b = strconv.AppendInt(b, int64(t.Year()), 10)
503	} else {
504		b = strconv.AppendInt(b, int64(-t.Year()), 10)
505	}
506
507	b = append(b, []byte{0x2c, 0x20}...)
508	b = append(b, te.daysWide[t.Weekday()]...)
509
510	return string(b)
511}
512
513// FmtTimeShort returns the short time representation of 't' for 'te'
514func (te *te) FmtTimeShort(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, te.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, []byte{0x20}...)
533
534	if t.Hour() < 12 {
535		b = append(b, te.periodsAbbreviated[0]...)
536	} else {
537		b = append(b, te.periodsAbbreviated[1]...)
538	}
539
540	return string(b)
541}
542
543// FmtTimeMedium returns the medium time representation of 't' for 'te'
544func (te *te) FmtTimeMedium(t time.Time) string {
545
546	b := make([]byte, 0, 32)
547
548	h := t.Hour()
549
550	if h > 12 {
551		h -= 12
552	}
553
554	b = strconv.AppendInt(b, int64(h), 10)
555	b = append(b, te.timeSeparator...)
556
557	if t.Minute() < 10 {
558		b = append(b, '0')
559	}
560
561	b = strconv.AppendInt(b, int64(t.Minute()), 10)
562	b = append(b, te.timeSeparator...)
563
564	if t.Second() < 10 {
565		b = append(b, '0')
566	}
567
568	b = strconv.AppendInt(b, int64(t.Second()), 10)
569	b = append(b, []byte{0x20}...)
570
571	if t.Hour() < 12 {
572		b = append(b, te.periodsAbbreviated[0]...)
573	} else {
574		b = append(b, te.periodsAbbreviated[1]...)
575	}
576
577	return string(b)
578}
579
580// FmtTimeLong returns the long time representation of 't' for 'te'
581func (te *te) FmtTimeLong(t time.Time) string {
582
583	b := make([]byte, 0, 32)
584
585	h := t.Hour()
586
587	if h > 12 {
588		h -= 12
589	}
590
591	b = strconv.AppendInt(b, int64(h), 10)
592	b = append(b, te.timeSeparator...)
593
594	if t.Minute() < 10 {
595		b = append(b, '0')
596	}
597
598	b = strconv.AppendInt(b, int64(t.Minute()), 10)
599	b = append(b, te.timeSeparator...)
600
601	if t.Second() < 10 {
602		b = append(b, '0')
603	}
604
605	b = strconv.AppendInt(b, int64(t.Second()), 10)
606	b = append(b, []byte{0x20}...)
607
608	if t.Hour() < 12 {
609		b = append(b, te.periodsAbbreviated[0]...)
610	} else {
611		b = append(b, te.periodsAbbreviated[1]...)
612	}
613
614	b = append(b, []byte{0x20}...)
615
616	tz, _ := t.Zone()
617	b = append(b, tz...)
618
619	return string(b)
620}
621
622// FmtTimeFull returns the full time representation of 't' for 'te'
623func (te *te) FmtTimeFull(t time.Time) string {
624
625	b := make([]byte, 0, 32)
626
627	h := t.Hour()
628
629	if h > 12 {
630		h -= 12
631	}
632
633	b = strconv.AppendInt(b, int64(h), 10)
634	b = append(b, te.timeSeparator...)
635
636	if t.Minute() < 10 {
637		b = append(b, '0')
638	}
639
640	b = strconv.AppendInt(b, int64(t.Minute()), 10)
641	b = append(b, te.timeSeparator...)
642
643	if t.Second() < 10 {
644		b = append(b, '0')
645	}
646
647	b = strconv.AppendInt(b, int64(t.Second()), 10)
648	b = append(b, []byte{0x20}...)
649
650	if t.Hour() < 12 {
651		b = append(b, te.periodsAbbreviated[0]...)
652	} else {
653		b = append(b, te.periodsAbbreviated[1]...)
654	}
655
656	b = append(b, []byte{0x20}...)
657
658	tz, _ := t.Zone()
659
660	if btz, ok := te.timezones[tz]; ok {
661		b = append(b, btz...)
662	} else {
663		b = append(b, tz...)
664	}
665
666	return string(b)
667}
668