1package as
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/gohugoio/locales"
9	"github.com/gohugoio/locales/currency"
10)
11
12type as 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 'as' locale
45func New() locales.Translator {
46	return &as{
47		locale:                 "as",
48		pluralsCardinal:        []locales.PluralRule{2, 6},
49		pluralsOrdinal:         []locales.PluralRule{2, 3, 4, 5, 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", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "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		currencyPositivePrefix: " ",
60		currencyNegativePrefix: " ",
61		monthsAbbreviated:      []string{"", "জানু", "ফেব্ৰু", "মাৰ্চ", "এপ্ৰিল", "মে’", "জুন", "জুলাই", "আগ", "ছেপ্তে", "অক্টো", "নৱে", "ডিচে"},
62		monthsNarrow:           []string{"", "জ", "ফ", "ম", "এ", "ম", "জ", "জ", "আ", "ছ", "অ", "ন", "ড"},
63		monthsWide:             []string{"", "জানুৱাৰী", "ফেব্ৰুৱাৰী", "মাৰ্চ", "এপ্ৰিল", "মে’", "জুন", "জুলাই", "আগষ্ট", "ছেপ্তেম্বৰ", "অক্টোবৰ", "নৱেম্বৰ", "ডিচেম্বৰ"},
64		daysAbbreviated:        []string{"দেও", "সোম", "মঙ্গল", "বুধ", "বৃহ", "শুক্ৰ", "শনি"},
65		daysNarrow:             []string{"দ", "স", "ম", "ব", "ব", "শ", "শ"},
66		daysShort:              []string{"দেও", "সোম", "মঙ্গল", "বুধ", "বৃহ", "শুক্ৰ", "শনি"},
67		daysWide:               []string{"দেওবাৰ", "সোমবাৰ", "মঙ্গলবাৰ", "বুধবাৰ", "বৃহস্পতিবাৰ", "শুক্ৰবাৰ", "শনিবাৰ"},
68		periodsAbbreviated:     []string{"পূৰ্বাহ্ন", "অপৰাহ্ন"},
69		periodsNarrow:          []string{"পূৰ্বাহ্ন", "অপৰাহ্ন"},
70		periodsWide:            []string{"পূৰ্বাহ্ন", "অপৰাহ্ন"},
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": "গ্ৰীণউইচ মান সময়", "GST": "উপসাগৰীয় মান সময়", "GYT": "গায়ানাৰ সময়", "HADT": "হাৱাই-এলিউশ্বনৰ ডেলাইট সময়", "HAST": "হাৱাই-এলিউশ্বনৰ মান সময়", "HAT": "নিউফাউণ্ডলেণ্ডৰ ডেলাইট সময়", "HECU": "কিউবাৰ ডেলাইট সময়", "HEEG": "পূব গ্ৰীণলেণ্ডৰ গ্ৰীষ্মকালীন সময়", "HENOMX": "উত্তৰ-পশ্চিম মেক্সিকোৰ ডেলাইট সময়", "HEOG": "পশ্চিম গ্ৰীণলেণ্ডৰ গ্ৰীষ্মকালীন সময়", "HEPM": "ছেইণ্ট পিয়েৰে আৰু মিকিউৱেলনৰ ডেলাইট সময়", "HEPMX": "মেক্সিকোৰ প্ৰশান্ত ডেলাইট সময়", "HKST": "হং কঙৰ গ্ৰীষ্মকালীন সময়", "HKT": "হং কঙৰ মান সময়", "HNCU": "কিউবাৰ মান সময়", "HNEG": "পূব গ্ৰীণলেণ্ডৰ মান সময়", "HNNOMX": "উত্তৰ-পশ্চিম মেক্সিকোৰ মান সময়", "HNOG": "পশ্চিম গ্ৰীণলেণ্ডৰ মান সময়", "HNPM": "ছেইণ্ট পিয়েৰে আৰু মিকিউৱেলনৰ মান সময়", "HNPMX": "মেক্সিকোৰ প্ৰশান্ত মান সময়", "HNT": "নিউফাউণ্ডলেণ্ডৰ মান সময়", "IST": "ভাৰতীয় মান সময়", "JDT": "জাপানৰ ডেলাইট সময়", "JST": "জাপানৰ মান সময়", "LHDT": "লৰ্ড হাওৰ ডেলাইট সময়", "LHST": "লৰ্ড হাওৰ মান সময়", "MDT": "উত্তৰ আমেৰিকাৰ পৰ্ব্বতীয় ডেলাইট সময়", "MESZ": "মধ্য ইউৰোপীয় গ্ৰীষ্মকালীন সময়", "MEZ": "মধ্য ইউৰোপীয় মান সময়", "MST": "উত্তৰ আমেৰিকাৰ পৰ্ব্বতীয় মান সময়", "MYT": "মালয়েচিয়াৰ সময়", "NZDT": "নিউজিলেণ্ডৰ ডেলাইট সময়", "NZST": "নিউজিলেণ্ডৰ মান সময়", "OESZ": "প্ৰাচ্য ইউৰোপীয় গ্ৰীষ্মকালীন সময়", "OEZ": "প্ৰাচ্য ইউৰোপীয় মান সময়", "PDT": "উত্তৰ আমেৰিকাৰ ডেলাইট সময়", "PST": "উত্তৰ আমেৰিকাৰ প্ৰশান্ত মান সময়", "SAST": "দক্ষিণ আফ্ৰিকাৰ মান সময়", "SGT": "ছিংগাপুৰৰ মান সময়", "SRT": "ছুৰিনামৰ সময়", "TMST": "তুৰ্কমেনিস্তানৰ গ্ৰীষ্মকালীন সময়", "TMT": "তুৰ্কমেনিস্তানৰ মান সময়", "UYST": "উৰুগুৱেৰ গ্ৰীষ্মকালীন সময়", "UYT": "উৰুগুৱেৰ মান সময়", "VET": "ভেনিজুৱেলাৰ সময়", "WARST": "পাশ্চাত্য আৰ্জেণ্টিনাৰ গ্ৰীষ্মকালীন সময়", "WART": "পাশ্চাত্য আৰ্জেণ্টিনাৰ মান সময়", "WAST": "পশ্চিম আফ্ৰিকাৰ গ্ৰীষ্মকালীন সময়", "WAT": "পশ্চিম আফ্ৰিকাৰ মান সময়", "WESZ": "পাশ্চাত্য ইউৰোপীয় গ্ৰীষ্মকালীন সময়", "WEZ": "পাশ্চাত্য ইউৰোপীয় মান সময়", "WIB": "পাশ্চাত্য ইণ্ডোনেচিয়াৰ সময়", "WIT": "প্ৰাচ্য ইণ্ডোনেচিয়াৰ সময়", "WITA": "মধ্য ইণ্ডোনেচিয়াৰ সময়", "∅∅∅": "ব্ৰাজিলিয়াৰ গ্ৰীষ্মকালীন সময়"},
75	}
76}
77
78// Locale returns the current translators string locale
79func (as *as) Locale() string {
80	return as.locale
81}
82
83// PluralsCardinal returns the list of cardinal plural rules associated with 'as'
84func (as *as) PluralsCardinal() []locales.PluralRule {
85	return as.pluralsCardinal
86}
87
88// PluralsOrdinal returns the list of ordinal plural rules associated with 'as'
89func (as *as) PluralsOrdinal() []locales.PluralRule {
90	return as.pluralsOrdinal
91}
92
93// PluralsRange returns the list of range plural rules associated with 'as'
94func (as *as) PluralsRange() []locales.PluralRule {
95	return as.pluralsRange
96}
97
98// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'as'
99func (as *as) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101	n := math.Abs(num)
102	i := int64(n)
103
104	if (i == 0) || (n == 1) {
105		return locales.PluralRuleOne
106	}
107
108	return locales.PluralRuleOther
109}
110
111// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'as'
112func (as *as) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113
114	n := math.Abs(num)
115
116	if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 {
117		return locales.PluralRuleOne
118	} else if n == 2 || n == 3 {
119		return locales.PluralRuleTwo
120	} else if n == 4 {
121		return locales.PluralRuleFew
122	} else if n == 6 {
123		return locales.PluralRuleMany
124	}
125
126	return locales.PluralRuleOther
127}
128
129// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'as'
130func (as *as) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
131
132	start := as.CardinalPluralRule(num1, v1)
133	end := as.CardinalPluralRule(num2, v2)
134
135	if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
136		return locales.PluralRuleOne
137	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
138		return locales.PluralRuleOther
139	}
140
141	return locales.PluralRuleOther
142
143}
144
145// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
146func (as *as) MonthAbbreviated(month time.Month) string {
147	return as.monthsAbbreviated[month]
148}
149
150// MonthsAbbreviated returns the locales abbreviated months
151func (as *as) MonthsAbbreviated() []string {
152	return as.monthsAbbreviated[1:]
153}
154
155// MonthNarrow returns the locales narrow month given the 'month' provided
156func (as *as) MonthNarrow(month time.Month) string {
157	return as.monthsNarrow[month]
158}
159
160// MonthsNarrow returns the locales narrow months
161func (as *as) MonthsNarrow() []string {
162	return as.monthsNarrow[1:]
163}
164
165// MonthWide returns the locales wide month given the 'month' provided
166func (as *as) MonthWide(month time.Month) string {
167	return as.monthsWide[month]
168}
169
170// MonthsWide returns the locales wide months
171func (as *as) MonthsWide() []string {
172	return as.monthsWide[1:]
173}
174
175// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
176func (as *as) WeekdayAbbreviated(weekday time.Weekday) string {
177	return as.daysAbbreviated[weekday]
178}
179
180// WeekdaysAbbreviated returns the locales abbreviated weekdays
181func (as *as) WeekdaysAbbreviated() []string {
182	return as.daysAbbreviated
183}
184
185// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
186func (as *as) WeekdayNarrow(weekday time.Weekday) string {
187	return as.daysNarrow[weekday]
188}
189
190// WeekdaysNarrow returns the locales narrow weekdays
191func (as *as) WeekdaysNarrow() []string {
192	return as.daysNarrow
193}
194
195// WeekdayShort returns the locales short weekday given the 'weekday' provided
196func (as *as) WeekdayShort(weekday time.Weekday) string {
197	return as.daysShort[weekday]
198}
199
200// WeekdaysShort returns the locales short weekdays
201func (as *as) WeekdaysShort() []string {
202	return as.daysShort
203}
204
205// WeekdayWide returns the locales wide weekday given the 'weekday' provided
206func (as *as) WeekdayWide(weekday time.Weekday) string {
207	return as.daysWide[weekday]
208}
209
210// WeekdaysWide returns the locales wide weekdays
211func (as *as) WeekdaysWide() []string {
212	return as.daysWide
213}
214
215// Decimal returns the decimal point of number
216func (as *as) Decimal() string {
217	return as.decimal
218}
219
220// Group returns the group of number
221func (as *as) Group() string {
222	return as.group
223}
224
225// Group returns the minus sign of number
226func (as *as) Minus() string {
227	return as.minus
228}
229
230// FmtNumber returns 'num' with digits/precision of 'v' for 'as' and handles both Whole and Real numbers based on 'v'
231func (as *as) FmtNumber(num float64, v uint64) string {
232
233	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
234	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
235	count := 0
236	inWhole := v == 0
237	inSecondary := false
238	groupThreshold := 3
239
240	b := make([]byte, 0, l)
241
242	for i := len(s) - 1; i >= 0; i-- {
243
244		if s[i] == '.' {
245			b = append(b, as.decimal[0])
246			inWhole = true
247			continue
248		}
249
250		if inWhole {
251
252			if count == groupThreshold {
253				b = append(b, as.group[0])
254				count = 1
255
256				if !inSecondary {
257					inSecondary = true
258					groupThreshold = 2
259				}
260			} else {
261				count++
262			}
263		}
264
265		b = append(b, s[i])
266	}
267
268	if num < 0 {
269		b = append(b, as.minus[0])
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	return string(b)
278}
279
280// FmtPercent returns 'num' with digits/precision of 'v' for 'as' and handles both Whole and Real numbers based on 'v'
281// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
282func (as *as) FmtPercent(num float64, v uint64) string {
283	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
284	l := len(s) + 3
285	b := make([]byte, 0, l)
286
287	for i := len(s) - 1; i >= 0; i-- {
288
289		if s[i] == '.' {
290			b = append(b, as.decimal[0])
291			continue
292		}
293
294		b = append(b, s[i])
295	}
296
297	if num < 0 {
298		b = append(b, as.minus[0])
299	}
300
301	// reverse
302	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
303		b[i], b[j] = b[j], b[i]
304	}
305
306	b = append(b, as.percent...)
307
308	return string(b)
309}
310
311// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'as'
312func (as *as) FmtCurrency(num float64, v uint64, currency currency.Type) string {
313
314	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
315	symbol := as.currencies[currency]
316	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
317	count := 0
318	inWhole := v == 0
319	inSecondary := false
320	groupThreshold := 3
321
322	b := make([]byte, 0, l)
323
324	for i := len(s) - 1; i >= 0; i-- {
325
326		if s[i] == '.' {
327			b = append(b, as.decimal[0])
328			inWhole = true
329			continue
330		}
331
332		if inWhole {
333
334			if count == groupThreshold {
335				b = append(b, as.group[0])
336				count = 1
337
338				if !inSecondary {
339					inSecondary = true
340					groupThreshold = 2
341				}
342			} else {
343				count++
344			}
345		}
346
347		b = append(b, s[i])
348	}
349
350	for j := len(symbol) - 1; j >= 0; j-- {
351		b = append(b, symbol[j])
352	}
353
354	for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- {
355		b = append(b, as.currencyPositivePrefix[j])
356	}
357
358	if num < 0 {
359		b = append(b, as.minus[0])
360	}
361
362	// reverse
363	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
364		b[i], b[j] = b[j], b[i]
365	}
366
367	if int(v) < 2 {
368
369		if v == 0 {
370			b = append(b, as.decimal...)
371		}
372
373		for i := 0; i < 2-int(v); i++ {
374			b = append(b, '0')
375		}
376	}
377
378	return string(b)
379}
380
381// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'as'
382// in accounting notation.
383func (as *as) FmtAccounting(num float64, v uint64, currency currency.Type) string {
384
385	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
386	symbol := as.currencies[currency]
387	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
388	count := 0
389	inWhole := v == 0
390	inSecondary := false
391	groupThreshold := 3
392
393	b := make([]byte, 0, l)
394
395	for i := len(s) - 1; i >= 0; i-- {
396
397		if s[i] == '.' {
398			b = append(b, as.decimal[0])
399			inWhole = true
400			continue
401		}
402
403		if inWhole {
404
405			if count == groupThreshold {
406				b = append(b, as.group[0])
407				count = 1
408
409				if !inSecondary {
410					inSecondary = true
411					groupThreshold = 2
412				}
413			} else {
414				count++
415			}
416		}
417
418		b = append(b, s[i])
419	}
420
421	if num < 0 {
422
423		for j := len(symbol) - 1; j >= 0; j-- {
424			b = append(b, symbol[j])
425		}
426
427		for j := len(as.currencyNegativePrefix) - 1; j >= 0; j-- {
428			b = append(b, as.currencyNegativePrefix[j])
429		}
430
431		b = append(b, as.minus[0])
432
433	} else {
434
435		for j := len(symbol) - 1; j >= 0; j-- {
436			b = append(b, symbol[j])
437		}
438
439		for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- {
440			b = append(b, as.currencyPositivePrefix[j])
441		}
442
443	}
444
445	// reverse
446	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
447		b[i], b[j] = b[j], b[i]
448	}
449
450	if int(v) < 2 {
451
452		if v == 0 {
453			b = append(b, as.decimal...)
454		}
455
456		for i := 0; i < 2-int(v); i++ {
457			b = append(b, '0')
458		}
459	}
460
461	return string(b)
462}
463
464// FmtDateShort returns the short date representation of 't' for 'as'
465func (as *as) FmtDateShort(t time.Time) string {
466
467	b := make([]byte, 0, 32)
468
469	b = strconv.AppendInt(b, int64(t.Day()), 10)
470	b = append(b, []byte{0x2d}...)
471	b = strconv.AppendInt(b, int64(t.Month()), 10)
472	b = append(b, []byte{0x2d}...)
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// FmtDateMedium returns the medium date representation of 't' for 'as'
484func (as *as) FmtDateMedium(t time.Time) string {
485
486	b := make([]byte, 0, 32)
487
488	if t.Day() < 10 {
489		b = append(b, '0')
490	}
491
492	b = strconv.AppendInt(b, int64(t.Day()), 10)
493	b = append(b, []byte{0x2d}...)
494
495	if t.Month() < 10 {
496		b = append(b, '0')
497	}
498
499	b = strconv.AppendInt(b, int64(t.Month()), 10)
500
501	b = append(b, []byte{0x2d}...)
502
503	if t.Year() > 0 {
504		b = strconv.AppendInt(b, int64(t.Year()), 10)
505	} else {
506		b = strconv.AppendInt(b, int64(-t.Year()), 10)
507	}
508
509	return string(b)
510}
511
512// FmtDateLong returns the long date representation of 't' for 'as'
513func (as *as) FmtDateLong(t time.Time) string {
514
515	b := make([]byte, 0, 32)
516
517	b = strconv.AppendInt(b, int64(t.Day()), 10)
518	b = append(b, []byte{0x20}...)
519	b = append(b, as.monthsWide[t.Month()]...)
520	b = append(b, []byte{0x2c, 0x20}...)
521
522	if t.Year() > 0 {
523		b = strconv.AppendInt(b, int64(t.Year()), 10)
524	} else {
525		b = strconv.AppendInt(b, int64(-t.Year()), 10)
526	}
527
528	return string(b)
529}
530
531// FmtDateFull returns the full date representation of 't' for 'as'
532func (as *as) FmtDateFull(t time.Time) string {
533
534	b := make([]byte, 0, 32)
535
536	b = append(b, as.daysWide[t.Weekday()]...)
537	b = append(b, []byte{0x2c, 0x20}...)
538	b = strconv.AppendInt(b, int64(t.Day()), 10)
539	b = append(b, []byte{0x20}...)
540	b = append(b, as.monthsWide[t.Month()]...)
541	b = append(b, []byte{0x2c, 0x20}...)
542
543	if t.Year() > 0 {
544		b = strconv.AppendInt(b, int64(t.Year()), 10)
545	} else {
546		b = strconv.AppendInt(b, int64(-t.Year()), 10)
547	}
548
549	return string(b)
550}
551
552// FmtTimeShort returns the short time representation of 't' for 'as'
553func (as *as) FmtTimeShort(t time.Time) string {
554
555	b := make([]byte, 0, 32)
556
557	if t.Hour() < 12 {
558		b = append(b, as.periodsAbbreviated[0]...)
559	} else {
560		b = append(b, as.periodsAbbreviated[1]...)
561	}
562
563	b = append(b, []byte{0x20}...)
564
565	h := t.Hour()
566
567	if h > 12 {
568		h -= 12
569	}
570
571	b = strconv.AppendInt(b, int64(h), 10)
572	b = append(b, []byte{0x2e}...)
573
574	if t.Minute() < 10 {
575		b = append(b, '0')
576	}
577
578	b = strconv.AppendInt(b, int64(t.Minute()), 10)
579
580	return string(b)
581}
582
583// FmtTimeMedium returns the medium time representation of 't' for 'as'
584func (as *as) FmtTimeMedium(t time.Time) string {
585
586	b := make([]byte, 0, 32)
587
588	if t.Hour() < 12 {
589		b = append(b, as.periodsAbbreviated[0]...)
590	} else {
591		b = append(b, as.periodsAbbreviated[1]...)
592	}
593
594	b = append(b, []byte{0x20}...)
595
596	h := t.Hour()
597
598	if h > 12 {
599		h -= 12
600	}
601
602	b = strconv.AppendInt(b, int64(h), 10)
603	b = append(b, []byte{0x2e}...)
604
605	if t.Minute() < 10 {
606		b = append(b, '0')
607	}
608
609	b = strconv.AppendInt(b, int64(t.Minute()), 10)
610	b = append(b, []byte{0x2e}...)
611
612	if t.Second() < 10 {
613		b = append(b, '0')
614	}
615
616	b = strconv.AppendInt(b, int64(t.Second()), 10)
617
618	return string(b)
619}
620
621// FmtTimeLong returns the long time representation of 't' for 'as'
622func (as *as) FmtTimeLong(t time.Time) string {
623
624	b := make([]byte, 0, 32)
625
626	if t.Hour() < 12 {
627		b = append(b, as.periodsAbbreviated[0]...)
628	} else {
629		b = append(b, as.periodsAbbreviated[1]...)
630	}
631
632	b = append(b, []byte{0x20}...)
633
634	h := t.Hour()
635
636	if h > 12 {
637		h -= 12
638	}
639
640	b = strconv.AppendInt(b, int64(h), 10)
641	b = append(b, []byte{0x2e}...)
642
643	if t.Minute() < 10 {
644		b = append(b, '0')
645	}
646
647	b = strconv.AppendInt(b, int64(t.Minute()), 10)
648	b = append(b, []byte{0x2e}...)
649
650	if t.Second() < 10 {
651		b = append(b, '0')
652	}
653
654	b = strconv.AppendInt(b, int64(t.Second()), 10)
655	b = append(b, []byte{0x20}...)
656
657	tz, _ := t.Zone()
658	b = append(b, tz...)
659
660	return string(b)
661}
662
663// FmtTimeFull returns the full time representation of 't' for 'as'
664func (as *as) FmtTimeFull(t time.Time) string {
665
666	b := make([]byte, 0, 32)
667
668	if t.Hour() < 12 {
669		b = append(b, as.periodsAbbreviated[0]...)
670	} else {
671		b = append(b, as.periodsAbbreviated[1]...)
672	}
673
674	b = append(b, []byte{0x20}...)
675
676	h := t.Hour()
677
678	if h > 12 {
679		h -= 12
680	}
681
682	b = strconv.AppendInt(b, int64(h), 10)
683	b = append(b, []byte{0x2e}...)
684
685	if t.Minute() < 10 {
686		b = append(b, '0')
687	}
688
689	b = strconv.AppendInt(b, int64(t.Minute()), 10)
690	b = append(b, []byte{0x2e}...)
691
692	if t.Second() < 10 {
693		b = append(b, '0')
694	}
695
696	b = strconv.AppendInt(b, int64(t.Second()), 10)
697	b = append(b, []byte{0x20}...)
698
699	tz, _ := t.Zone()
700
701	if btz, ok := as.timezones[tz]; ok {
702		b = append(b, btz...)
703	} else {
704		b = append(b, tz...)
705	}
706
707	return string(b)
708}
709