1package be
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/go-playground/locales"
9	"github.com/go-playground/locales/currency"
10)
11
12type be 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 'be' locale
46func New() locales.Translator {
47	return &be{
48		locale:                 "be",
49		pluralsCardinal:        []locales.PluralRule{2, 4, 5, 6},
50		pluralsOrdinal:         []locales.PluralRule{4, 6},
51		pluralsRange:           []locales.PluralRule{2, 4, 5, 6},
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", "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", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "Br", "BYR", "BZD", "CAD", "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", "¥", "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", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "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", "₽", "RUR", "RWF", "SAR", "SBD", "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", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "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"},
60		percentSuffix:          " ",
61		currencyPositiveSuffix: " ",
62		currencyNegativeSuffix: " ",
63		monthsAbbreviated:      []string{"", "сту", "лют", "сак", "кра", "мая", "чэр", "ліп", "жні", "вер", "кас", "ліс", "сне"},
64		monthsNarrow:           []string{"", "с", "л", "с", "к", "м", "ч", "л", "ж", "в", "к", "л", "с"},
65		monthsWide:             []string{"", "студзеня", "лютага", "сакавіка", "красавіка", "мая", "чэрвеня", "ліпеня", "жніўня", "верасня", "кастрычніка", "лістапада", "снежня"},
66		daysAbbreviated:        []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"},
67		daysNarrow:             []string{"н", "п", "а", "с", "ч", "п", "с"},
68		daysShort:              []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"},
69		daysWide:               []string{"нядзеля", "панядзелак", "аўторак", "серада", "чацвер", "пятніца", "субота"},
70		periodsAbbreviated:     []string{"AM", "PM"},
71		periodsNarrow:          []string{"am", "pm"},
72		periodsWide:            []string{"AM", "PM"},
73		erasAbbreviated:        []string{"да н.э.", "н.э."},
74		erasNarrow:             []string{"", ""},
75		erasWide:               []string{"да нараджэння Хрыстова", "ад нараджэння Хрыстова"},
76		timezones:              map[string]string{"AEST": "Стандартны час усходняй Аўстраліі", "NZST": "Стандартны час Новай Зеландыі", "AKST": "Стандартны час Аляскі", "WARST": "Летні час Заходняй Аргенціны", "HENOMX": "Паўночна-заходні мексіканскі летні час", "PST": "Ціхаакіянскі стандартны час", "ACDT": "Летні час цэнтральнай Аўстраліі", "ACWDT": "Заходні летні час Цэнтральнай Аўстраліі", "MEZ": "Цэнтральнаеўрапейскі стандартны час", "HNNOMX": "Паўночна-заходні мексіканскі стандартны час", "TMST": "Летні час Туркменістана", "JST": "Стандартны час Японіі", "HKST": "Летні час Ганконга", "IST": "Час Індыі", "CHADT": "Летні час Чатэма", "NZDT": "Летні час Новай Зеландыі", "EDT": "Паўночнаамерыканскі ўсходні летні час", "ChST": "Час Чамора", "CHAST": "Стандартны час Чатэма", "CDT": "Паўночнаамерыканскі цэнтральны летні час", "GFT": "Час Французскай Гвіяны", "ACWST": "Заходні стандартны час Цэнтральнай Аўстраліі", "MESZ": "Цэнтральнаеўрапейскі летні час", "MST": "MST", "OEZ": "Усходнееўрапейскі стандартны час", "HNCU": "Стандартны час Кубы", "WESZ": "Заходнееўрапейскі летні час", "HNEG": "Стандартны час Усходняй Грэнландыі", "HAT": "Ньюфаўндлендскі летні час", "AWST": "Стандартны час заходняй Аўстраліі", "ADT": "Атлантычны летні час", "JDT": "Летні час Японіі", "ACST": "Стандартны час цэнтральнай Аўстраліі", "ART": "Аргенцінскі стандартны час", "PDT": "Ціхаакіянскі летні час", "SAST": "Паўднёваафрыканскі час", "ECT": "Эквадорскі час", "MDT": "MDT", "HAST": "Гавайска-Алеуцкі стандартны час", "HECU": "Летні час Кубы", "HNPM": "Стандартны час Сен-П’ер і Мікелон", "CAT": "Цэнтральнаафрыканскі час", "BT": "Час Бутана", "WAT": "Заходнеафрыканскі стандартны час", "MYT": "Час Малайзіі", "WIT": "Усходнеінданезійскі час", "HADT": "Гавайска-Алеуцкі летні час", "HNPMX": "Мексіканскі ціхаакіянскі стандатны час", "COST": "Калумбійскі летні час", "GMT": "Час па Грынвічы", "AWDT": "Летні час заходняй Аўстраліі", "HEPMX": "Мексіканскі ціхаакіянскі летні час", "WIB": "Заходнеінданезійскі час", "LHDT": "Летні час Лорд-Хау", "WART": "Стандартны час Заходняй Аргенціны", "CLT": "Чылійскі стандартны час", "ARST": "Аргенцінскі летні час", "GYT": "Час Гаяны", "WEZ": "Заходнееўрапейскі стандартны час", "BOT": "Балівійскі час", "SGT": "Сінгапурскі час", "HEEG": "Летні час Усходняй Грэнландыі", "HEOG": "Летні час Заходняй Грэнландыі", "HNT": "Ньюфаўндлендскі стандартны час", "UYT": "Уругвайскі стандартны час", "WAST": "Заходнеафрыканскі летні час", "HKT": "Стандартны час Ганконга", "TMT": "Стандартны час Туркменістана", "AEDT": "Летні час усходняй Аўстраліі", "AKDT": "Летні час Аляскі", "EST": "Паўночнаамерыканскі ўсходні стандартны час", "WITA": "Цэнтральнаінданезійскі час", "EAT": "Усходнеафрыканскі час", "CLST": "Чылійскі летні час", "LHST": "Стандартны час Лорд-Хау", "∅∅∅": "Перуанскі летні час", "HNOG": "Стандартны час Заходняй Грэнландыі", "OESZ": "Усходнееўрапейскі летні час", "COT": "Калумбійскі стандартны час", "UYST": "Уругвайскі летні час", "CST": "Паўночнаамерыканскі цэнтральны стандартны час", "AST": "Атлантычны стандартны час", "VET": "Венесуэльскі час", "HEPM": "Стандартны летні час Сен-П’ер і Мікелон", "SRT": "Час Сурынама"},
77	}
78}
79
80// Locale returns the current translators string locale
81func (be *be) Locale() string {
82	return be.locale
83}
84
85// PluralsCardinal returns the list of cardinal plural rules associated with 'be'
86func (be *be) PluralsCardinal() []locales.PluralRule {
87	return be.pluralsCardinal
88}
89
90// PluralsOrdinal returns the list of ordinal plural rules associated with 'be'
91func (be *be) PluralsOrdinal() []locales.PluralRule {
92	return be.pluralsOrdinal
93}
94
95// PluralsRange returns the list of range plural rules associated with 'be'
96func (be *be) PluralsRange() []locales.PluralRule {
97	return be.pluralsRange
98}
99
100// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'be'
101func (be *be) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
102
103	n := math.Abs(num)
104	nMod10 := math.Mod(n, 10)
105	nMod100 := math.Mod(n, 100)
106
107	if nMod10 == 1 && nMod100 != 11 {
108		return locales.PluralRuleOne
109	} else if nMod10 >= 2 && nMod10 <= 4 && (nMod100 < 12 || nMod100 > 14) {
110		return locales.PluralRuleFew
111	} else if (nMod10 == 0) || (nMod10 >= 5 && nMod10 <= 9) || (nMod100 >= 11 && nMod100 <= 14) {
112		return locales.PluralRuleMany
113	}
114
115	return locales.PluralRuleOther
116}
117
118// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'be'
119func (be *be) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
120
121	n := math.Abs(num)
122	nMod10 := math.Mod(n, 10)
123	nMod100 := math.Mod(n, 100)
124
125	if (nMod10 == 2 || nMod10 == 3) && (nMod100 != 12 && nMod100 != 13) {
126		return locales.PluralRuleFew
127	}
128
129	return locales.PluralRuleOther
130}
131
132// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'be'
133func (be *be) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
134
135	start := be.CardinalPluralRule(num1, v1)
136	end := be.CardinalPluralRule(num2, v2)
137
138	if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
139		return locales.PluralRuleOne
140	} else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
141		return locales.PluralRuleFew
142	} else if start == locales.PluralRuleOne && end == locales.PluralRuleMany {
143		return locales.PluralRuleMany
144	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
145		return locales.PluralRuleOther
146	} else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
147		return locales.PluralRuleOne
148	} else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
149		return locales.PluralRuleFew
150	} else if start == locales.PluralRuleFew && end == locales.PluralRuleMany {
151		return locales.PluralRuleMany
152	} else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
153		return locales.PluralRuleOther
154	} else if start == locales.PluralRuleMany && end == locales.PluralRuleOne {
155		return locales.PluralRuleOne
156	} else if start == locales.PluralRuleMany && end == locales.PluralRuleFew {
157		return locales.PluralRuleFew
158	} else if start == locales.PluralRuleMany && end == locales.PluralRuleMany {
159		return locales.PluralRuleMany
160	} else if start == locales.PluralRuleMany && end == locales.PluralRuleOther {
161		return locales.PluralRuleOther
162	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
163		return locales.PluralRuleOne
164	} else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
165		return locales.PluralRuleFew
166	} else if start == locales.PluralRuleOther && end == locales.PluralRuleMany {
167		return locales.PluralRuleMany
168	}
169
170	return locales.PluralRuleOther
171
172}
173
174// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
175func (be *be) MonthAbbreviated(month time.Month) string {
176	return be.monthsAbbreviated[month]
177}
178
179// MonthsAbbreviated returns the locales abbreviated months
180func (be *be) MonthsAbbreviated() []string {
181	return be.monthsAbbreviated[1:]
182}
183
184// MonthNarrow returns the locales narrow month given the 'month' provided
185func (be *be) MonthNarrow(month time.Month) string {
186	return be.monthsNarrow[month]
187}
188
189// MonthsNarrow returns the locales narrow months
190func (be *be) MonthsNarrow() []string {
191	return be.monthsNarrow[1:]
192}
193
194// MonthWide returns the locales wide month given the 'month' provided
195func (be *be) MonthWide(month time.Month) string {
196	return be.monthsWide[month]
197}
198
199// MonthsWide returns the locales wide months
200func (be *be) MonthsWide() []string {
201	return be.monthsWide[1:]
202}
203
204// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
205func (be *be) WeekdayAbbreviated(weekday time.Weekday) string {
206	return be.daysAbbreviated[weekday]
207}
208
209// WeekdaysAbbreviated returns the locales abbreviated weekdays
210func (be *be) WeekdaysAbbreviated() []string {
211	return be.daysAbbreviated
212}
213
214// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
215func (be *be) WeekdayNarrow(weekday time.Weekday) string {
216	return be.daysNarrow[weekday]
217}
218
219// WeekdaysNarrow returns the locales narrow weekdays
220func (be *be) WeekdaysNarrow() []string {
221	return be.daysNarrow
222}
223
224// WeekdayShort returns the locales short weekday given the 'weekday' provided
225func (be *be) WeekdayShort(weekday time.Weekday) string {
226	return be.daysShort[weekday]
227}
228
229// WeekdaysShort returns the locales short weekdays
230func (be *be) WeekdaysShort() []string {
231	return be.daysShort
232}
233
234// WeekdayWide returns the locales wide weekday given the 'weekday' provided
235func (be *be) WeekdayWide(weekday time.Weekday) string {
236	return be.daysWide[weekday]
237}
238
239// WeekdaysWide returns the locales wide weekdays
240func (be *be) WeekdaysWide() []string {
241	return be.daysWide
242}
243
244// Decimal returns the decimal point of number
245func (be *be) Decimal() string {
246	return be.decimal
247}
248
249// Group returns the group of number
250func (be *be) Group() string {
251	return be.group
252}
253
254// Group returns the minus sign of number
255func (be *be) Minus() string {
256	return be.minus
257}
258
259// FmtNumber returns 'num' with digits/precision of 'v' for 'be' and handles both Whole and Real numbers based on 'v'
260func (be *be) FmtNumber(num float64, v uint64) string {
261
262	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
263	l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
264	count := 0
265	inWhole := v == 0
266	b := make([]byte, 0, l)
267
268	for i := len(s) - 1; i >= 0; i-- {
269
270		if s[i] == '.' {
271			b = append(b, be.decimal[0])
272			inWhole = true
273			continue
274		}
275
276		if inWhole {
277			if count == 3 {
278				for j := len(be.group) - 1; j >= 0; j-- {
279					b = append(b, be.group[j])
280				}
281				count = 1
282			} else {
283				count++
284			}
285		}
286
287		b = append(b, s[i])
288	}
289
290	if num < 0 {
291		b = append(b, be.minus[0])
292	}
293
294	// reverse
295	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
296		b[i], b[j] = b[j], b[i]
297	}
298
299	return string(b)
300}
301
302// FmtPercent returns 'num' with digits/precision of 'v' for 'be' and handles both Whole and Real numbers based on 'v'
303// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
304func (be *be) FmtPercent(num float64, v uint64) string {
305	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
306	l := len(s) + 5
307	b := make([]byte, 0, l)
308
309	for i := len(s) - 1; i >= 0; i-- {
310
311		if s[i] == '.' {
312			b = append(b, be.decimal[0])
313			continue
314		}
315
316		b = append(b, s[i])
317	}
318
319	if num < 0 {
320		b = append(b, be.minus[0])
321	}
322
323	// reverse
324	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
325		b[i], b[j] = b[j], b[i]
326	}
327
328	b = append(b, be.percentSuffix...)
329
330	b = append(b, be.percent...)
331
332	return string(b)
333}
334
335// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'be'
336func (be *be) FmtCurrency(num float64, v uint64, currency currency.Type) string {
337
338	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339	symbol := be.currencies[currency]
340	l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
341	count := 0
342	inWhole := v == 0
343	b := make([]byte, 0, l)
344
345	for i := len(s) - 1; i >= 0; i-- {
346
347		if s[i] == '.' {
348			b = append(b, be.decimal[0])
349			inWhole = true
350			continue
351		}
352
353		if inWhole {
354			if count == 3 {
355				for j := len(be.group) - 1; j >= 0; j-- {
356					b = append(b, be.group[j])
357				}
358				count = 1
359			} else {
360				count++
361			}
362		}
363
364		b = append(b, s[i])
365	}
366
367	if num < 0 {
368		b = append(b, be.minus[0])
369	}
370
371	// reverse
372	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
373		b[i], b[j] = b[j], b[i]
374	}
375
376	if int(v) < 2 {
377
378		if v == 0 {
379			b = append(b, be.decimal...)
380		}
381
382		for i := 0; i < 2-int(v); i++ {
383			b = append(b, '0')
384		}
385	}
386
387	b = append(b, be.currencyPositiveSuffix...)
388
389	b = append(b, symbol...)
390
391	return string(b)
392}
393
394// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'be'
395// in accounting notation.
396func (be *be) FmtAccounting(num float64, v uint64, currency currency.Type) string {
397
398	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
399	symbol := be.currencies[currency]
400	l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
401	count := 0
402	inWhole := v == 0
403	b := make([]byte, 0, l)
404
405	for i := len(s) - 1; i >= 0; i-- {
406
407		if s[i] == '.' {
408			b = append(b, be.decimal[0])
409			inWhole = true
410			continue
411		}
412
413		if inWhole {
414			if count == 3 {
415				for j := len(be.group) - 1; j >= 0; j-- {
416					b = append(b, be.group[j])
417				}
418				count = 1
419			} else {
420				count++
421			}
422		}
423
424		b = append(b, s[i])
425	}
426
427	if num < 0 {
428
429		b = append(b, be.minus[0])
430
431	}
432
433	// reverse
434	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
435		b[i], b[j] = b[j], b[i]
436	}
437
438	if int(v) < 2 {
439
440		if v == 0 {
441			b = append(b, be.decimal...)
442		}
443
444		for i := 0; i < 2-int(v); i++ {
445			b = append(b, '0')
446		}
447	}
448
449	if num < 0 {
450		b = append(b, be.currencyNegativeSuffix...)
451		b = append(b, symbol...)
452	} else {
453
454		b = append(b, be.currencyPositiveSuffix...)
455		b = append(b, symbol...)
456	}
457
458	return string(b)
459}
460
461// FmtDateShort returns the short date representation of 't' for 'be'
462func (be *be) FmtDateShort(t time.Time) string {
463
464	b := make([]byte, 0, 32)
465
466	b = strconv.AppendInt(b, int64(t.Day()), 10)
467	b = append(b, []byte{0x2e}...)
468
469	if t.Month() < 10 {
470		b = append(b, '0')
471	}
472
473	b = strconv.AppendInt(b, int64(t.Month()), 10)
474
475	b = append(b, []byte{0x2e}...)
476
477	if t.Year() > 9 {
478		b = append(b, strconv.Itoa(t.Year())[2:]...)
479	} else {
480		b = append(b, strconv.Itoa(t.Year())[1:]...)
481	}
482
483	return string(b)
484}
485
486// FmtDateMedium returns the medium date representation of 't' for 'be'
487func (be *be) FmtDateMedium(t time.Time) string {
488
489	b := make([]byte, 0, 32)
490
491	b = strconv.AppendInt(b, int64(t.Day()), 10)
492	b = append(b, []byte{0x2e}...)
493
494	if t.Month() < 10 {
495		b = append(b, '0')
496	}
497
498	b = strconv.AppendInt(b, int64(t.Month()), 10)
499
500	b = append(b, []byte{0x2e}...)
501
502	if t.Year() > 0 {
503		b = strconv.AppendInt(b, int64(t.Year()), 10)
504	} else {
505		b = strconv.AppendInt(b, int64(-t.Year()), 10)
506	}
507
508	return string(b)
509}
510
511// FmtDateLong returns the long date representation of 't' for 'be'
512func (be *be) FmtDateLong(t time.Time) string {
513
514	b := make([]byte, 0, 32)
515
516	b = strconv.AppendInt(b, int64(t.Day()), 10)
517	b = append(b, []byte{0x20}...)
518	b = append(b, be.monthsWide[t.Month()]...)
519	b = append(b, []byte{0x20}...)
520
521	if t.Year() > 0 {
522		b = strconv.AppendInt(b, int64(t.Year()), 10)
523	} else {
524		b = strconv.AppendInt(b, int64(-t.Year()), 10)
525	}
526
527	b = append(b, []byte{0x20, 0xd0, 0xb3}...)
528	b = append(b, []byte{0x2e}...)
529
530	return string(b)
531}
532
533// FmtDateFull returns the full date representation of 't' for 'be'
534func (be *be) FmtDateFull(t time.Time) string {
535
536	b := make([]byte, 0, 32)
537
538	b = append(b, be.daysWide[t.Weekday()]...)
539	b = append(b, []byte{0x2c, 0x20}...)
540	b = strconv.AppendInt(b, int64(t.Day()), 10)
541	b = append(b, []byte{0x20}...)
542	b = append(b, be.monthsWide[t.Month()]...)
543	b = append(b, []byte{0x20}...)
544
545	if t.Year() > 0 {
546		b = strconv.AppendInt(b, int64(t.Year()), 10)
547	} else {
548		b = strconv.AppendInt(b, int64(-t.Year()), 10)
549	}
550
551	b = append(b, []byte{0x20, 0xd0, 0xb3}...)
552	b = append(b, []byte{0x2e}...)
553
554	return string(b)
555}
556
557// FmtTimeShort returns the short time representation of 't' for 'be'
558func (be *be) FmtTimeShort(t time.Time) string {
559
560	b := make([]byte, 0, 32)
561
562	if t.Hour() < 10 {
563		b = append(b, '0')
564	}
565
566	b = strconv.AppendInt(b, int64(t.Hour()), 10)
567	b = append(b, be.timeSeparator...)
568
569	if t.Minute() < 10 {
570		b = append(b, '0')
571	}
572
573	b = strconv.AppendInt(b, int64(t.Minute()), 10)
574
575	return string(b)
576}
577
578// FmtTimeMedium returns the medium time representation of 't' for 'be'
579func (be *be) FmtTimeMedium(t time.Time) string {
580
581	b := make([]byte, 0, 32)
582
583	if t.Hour() < 10 {
584		b = append(b, '0')
585	}
586
587	b = strconv.AppendInt(b, int64(t.Hour()), 10)
588	b = append(b, be.timeSeparator...)
589
590	if t.Minute() < 10 {
591		b = append(b, '0')
592	}
593
594	b = strconv.AppendInt(b, int64(t.Minute()), 10)
595	b = append(b, be.timeSeparator...)
596
597	if t.Second() < 10 {
598		b = append(b, '0')
599	}
600
601	b = strconv.AppendInt(b, int64(t.Second()), 10)
602
603	return string(b)
604}
605
606// FmtTimeLong returns the long time representation of 't' for 'be'
607func (be *be) FmtTimeLong(t time.Time) string {
608
609	b := make([]byte, 0, 32)
610
611	if t.Hour() < 10 {
612		b = append(b, '0')
613	}
614
615	b = strconv.AppendInt(b, int64(t.Hour()), 10)
616	b = append(b, be.timeSeparator...)
617
618	if t.Minute() < 10 {
619		b = append(b, '0')
620	}
621
622	b = strconv.AppendInt(b, int64(t.Minute()), 10)
623	b = append(b, be.timeSeparator...)
624
625	if t.Second() < 10 {
626		b = append(b, '0')
627	}
628
629	b = strconv.AppendInt(b, int64(t.Second()), 10)
630	b = append(b, []byte{0x20}...)
631
632	tz, _ := t.Zone()
633	b = append(b, tz...)
634
635	return string(b)
636}
637
638// FmtTimeFull returns the full time representation of 't' for 'be'
639func (be *be) FmtTimeFull(t time.Time) string {
640
641	b := make([]byte, 0, 32)
642
643	if t.Hour() < 10 {
644		b = append(b, '0')
645	}
646
647	b = strconv.AppendInt(b, int64(t.Hour()), 10)
648	b = append(b, be.timeSeparator...)
649
650	if t.Minute() < 10 {
651		b = append(b, '0')
652	}
653
654	b = strconv.AppendInt(b, int64(t.Minute()), 10)
655	b = append(b, be.timeSeparator...)
656
657	if t.Second() < 10 {
658		b = append(b, '0')
659	}
660
661	b = strconv.AppendInt(b, int64(t.Second()), 10)
662	b = append(b, []byte{0x2c, 0x20}...)
663
664	tz, _ := t.Zone()
665
666	if btz, ok := be.timezones[tz]; ok {
667		b = append(b, btz...)
668	} else {
669		b = append(b, tz...)
670	}
671
672	return string(b)
673}
674