1 package mas_TZ
2
3 import (
4 "math"
5 "strconv"
6 "time"
7
8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
10 )
11
12 type mas_TZ 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
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
45 func New() locales.Translator {
46 return &mas_TZ{
47 locale: "mas_TZ",
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: nil,
50 pluralsRange: nil,
51 timeSeparator: ":",
52 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", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "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", "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", "TWD", "TSh", "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"},
53 currencyNegativePrefix: "(",
54 currencyNegativeSuffix: ")",
55 monthsAbbreviated: []string{"", "Dal", "Ará", "Ɔɛn", "Doy", "Lép", "Rok", "Sás", "Bɔ́r", "Kús", "Gís", "Shʉ́", "Ntʉ́"},
56 monthsWide: []string{"", "Oladalʉ́", "Arát", "Ɔɛnɨ́ɔɨŋɔk", "Olodoyíóríê inkókúâ", "Oloilépūnyīē inkókúâ", "Kújúɔrɔk", "Mórusásin", "Ɔlɔ́ɨ́bɔ́rárɛ", "Kúshîn", "Olgísan", "Pʉshʉ́ka", "Ntʉ́ŋʉ́s"},
57 daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"},
58 daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"},
59 daysWide: []string{"Jumapílí", "Jumatátu", "Jumane", "Jumatánɔ", "Alaámisi", "Jumáa", "Jumamósi"},
60 periodsAbbreviated: []string{"Ɛnkakɛnyá", "Ɛndámâ"},
61 periodsWide: []string{"Ɛnkakɛnyá", "Ɛndámâ"},
62 erasAbbreviated: []string{"MY", "EY"},
63 erasNarrow: []string{"", ""},
64 erasWide: []string{"Meínō Yɛ́sʉ", "Eínō Yɛ́sʉ"},
65 timezones: map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "ADT", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "AST", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT", "EST": "EST", "GFT": "GFT", "GMT": "GMT", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "IST", "JDT": "JDT", "JST": "JST", "LHDT": "LHDT", "LHST": "LHST", "MDT": "MDT", "MESZ": "MESZ", "MEZ": "MEZ", "MST": "MST", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "OESZ", "OEZ": "OEZ", "PDT": "PDT", "PST": "PST", "SAST": "SAST", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "WAST", "WAT": "WAT", "WESZ": "WESZ", "WEZ": "WEZ", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
66 }
67 }
68
69
70 func (mas *mas_TZ) Locale() string {
71 return mas.locale
72 }
73
74
75 func (mas *mas_TZ) PluralsCardinal() []locales.PluralRule {
76 return mas.pluralsCardinal
77 }
78
79
80 func (mas *mas_TZ) PluralsOrdinal() []locales.PluralRule {
81 return mas.pluralsOrdinal
82 }
83
84
85 func (mas *mas_TZ) PluralsRange() []locales.PluralRule {
86 return mas.pluralsRange
87 }
88
89
90 func (mas *mas_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
91
92 n := math.Abs(num)
93
94 if n == 1 {
95 return locales.PluralRuleOne
96 }
97
98 return locales.PluralRuleOther
99 }
100
101
102 func (mas *mas_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
103 return locales.PluralRuleUnknown
104 }
105
106
107 func (mas *mas_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
108 return locales.PluralRuleUnknown
109 }
110
111
112 func (mas *mas_TZ) MonthAbbreviated(month time.Month) string {
113 return mas.monthsAbbreviated[month]
114 }
115
116
117 func (mas *mas_TZ) MonthsAbbreviated() []string {
118 return mas.monthsAbbreviated[1:]
119 }
120
121
122 func (mas *mas_TZ) MonthNarrow(month time.Month) string {
123 return mas.monthsNarrow[month]
124 }
125
126
127 func (mas *mas_TZ) MonthsNarrow() []string {
128 return nil
129 }
130
131
132 func (mas *mas_TZ) MonthWide(month time.Month) string {
133 return mas.monthsWide[month]
134 }
135
136
137 func (mas *mas_TZ) MonthsWide() []string {
138 return mas.monthsWide[1:]
139 }
140
141
142 func (mas *mas_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
143 return mas.daysAbbreviated[weekday]
144 }
145
146
147 func (mas *mas_TZ) WeekdaysAbbreviated() []string {
148 return mas.daysAbbreviated
149 }
150
151
152 func (mas *mas_TZ) WeekdayNarrow(weekday time.Weekday) string {
153 return mas.daysNarrow[weekday]
154 }
155
156
157 func (mas *mas_TZ) WeekdaysNarrow() []string {
158 return mas.daysNarrow
159 }
160
161
162 func (mas *mas_TZ) WeekdayShort(weekday time.Weekday) string {
163 return mas.daysShort[weekday]
164 }
165
166
167 func (mas *mas_TZ) WeekdaysShort() []string {
168 return mas.daysShort
169 }
170
171
172 func (mas *mas_TZ) WeekdayWide(weekday time.Weekday) string {
173 return mas.daysWide[weekday]
174 }
175
176
177 func (mas *mas_TZ) WeekdaysWide() []string {
178 return mas.daysWide
179 }
180
181
182 func (mas *mas_TZ) Decimal() string {
183 return mas.decimal
184 }
185
186
187 func (mas *mas_TZ) Group() string {
188 return mas.group
189 }
190
191
192 func (mas *mas_TZ) Minus() string {
193 return mas.minus
194 }
195
196
197 func (mas *mas_TZ) FmtNumber(num float64, v uint64) string {
198
199 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
200 }
201
202
203
204 func (mas *mas_TZ) FmtPercent(num float64, v uint64) string {
205 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 }
207
208
209 func (mas *mas_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
210
211 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212 symbol := mas.currencies[currency]
213 l := len(s) + len(symbol) + 0
214 count := 0
215 inWhole := v == 0
216 b := make([]byte, 0, l)
217
218 for i := len(s) - 1; i >= 0; i-- {
219
220 if s[i] == '.' {
221 b = append(b, mas.decimal[0])
222 inWhole = true
223 continue
224 }
225
226 if inWhole {
227 if count == 3 {
228 b = append(b, mas.group[0])
229 count = 1
230 } else {
231 count++
232 }
233 }
234
235 b = append(b, s[i])
236 }
237
238 for j := len(symbol) - 1; j >= 0; j-- {
239 b = append(b, symbol[j])
240 }
241
242 if num < 0 {
243 b = append(b, mas.minus[0])
244 }
245
246
247 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
248 b[i], b[j] = b[j], b[i]
249 }
250
251 if int(v) < 2 {
252
253 if v == 0 {
254 b = append(b, mas.decimal...)
255 }
256
257 for i := 0; i < 2-int(v); i++ {
258 b = append(b, '0')
259 }
260 }
261
262 return string(b)
263 }
264
265
266
267 func (mas *mas_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
268
269 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270 symbol := mas.currencies[currency]
271 l := len(s) + len(symbol) + 2
272 count := 0
273 inWhole := v == 0
274 b := make([]byte, 0, l)
275
276 for i := len(s) - 1; i >= 0; i-- {
277
278 if s[i] == '.' {
279 b = append(b, mas.decimal[0])
280 inWhole = true
281 continue
282 }
283
284 if inWhole {
285 if count == 3 {
286 b = append(b, mas.group[0])
287 count = 1
288 } else {
289 count++
290 }
291 }
292
293 b = append(b, s[i])
294 }
295
296 if num < 0 {
297
298 for j := len(symbol) - 1; j >= 0; j-- {
299 b = append(b, symbol[j])
300 }
301
302 b = append(b, mas.currencyNegativePrefix[0])
303
304 } else {
305
306 for j := len(symbol) - 1; j >= 0; j-- {
307 b = append(b, symbol[j])
308 }
309
310 }
311
312
313 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
314 b[i], b[j] = b[j], b[i]
315 }
316
317 if int(v) < 2 {
318
319 if v == 0 {
320 b = append(b, mas.decimal...)
321 }
322
323 for i := 0; i < 2-int(v); i++ {
324 b = append(b, '0')
325 }
326 }
327
328 if num < 0 {
329 b = append(b, mas.currencyNegativeSuffix...)
330 }
331
332 return string(b)
333 }
334
335
336 func (mas *mas_TZ) FmtDateShort(t time.Time) string {
337
338 b := make([]byte, 0, 32)
339
340 if t.Day() < 10 {
341 b = append(b, '0')
342 }
343
344 b = strconv.AppendInt(b, int64(t.Day()), 10)
345 b = append(b, []byte{0x2f}...)
346
347 if t.Month() < 10 {
348 b = append(b, '0')
349 }
350
351 b = strconv.AppendInt(b, int64(t.Month()), 10)
352
353 b = append(b, []byte{0x2f}...)
354
355 if t.Year() > 0 {
356 b = strconv.AppendInt(b, int64(t.Year()), 10)
357 } else {
358 b = strconv.AppendInt(b, int64(-t.Year()), 10)
359 }
360
361 return string(b)
362 }
363
364
365 func (mas *mas_TZ) FmtDateMedium(t time.Time) string {
366
367 b := make([]byte, 0, 32)
368
369 b = strconv.AppendInt(b, int64(t.Day()), 10)
370 b = append(b, []byte{0x20}...)
371 b = append(b, mas.monthsAbbreviated[t.Month()]...)
372 b = append(b, []byte{0x20}...)
373
374 if t.Year() > 0 {
375 b = strconv.AppendInt(b, int64(t.Year()), 10)
376 } else {
377 b = strconv.AppendInt(b, int64(-t.Year()), 10)
378 }
379
380 return string(b)
381 }
382
383
384 func (mas *mas_TZ) FmtDateLong(t time.Time) string {
385
386 b := make([]byte, 0, 32)
387
388 b = strconv.AppendInt(b, int64(t.Day()), 10)
389 b = append(b, []byte{0x20}...)
390 b = append(b, mas.monthsWide[t.Month()]...)
391 b = append(b, []byte{0x20}...)
392
393 if t.Year() > 0 {
394 b = strconv.AppendInt(b, int64(t.Year()), 10)
395 } else {
396 b = strconv.AppendInt(b, int64(-t.Year()), 10)
397 }
398
399 return string(b)
400 }
401
402
403 func (mas *mas_TZ) FmtDateFull(t time.Time) string {
404
405 b := make([]byte, 0, 32)
406
407 b = append(b, mas.daysWide[t.Weekday()]...)
408 b = append(b, []byte{0x2c, 0x20}...)
409 b = strconv.AppendInt(b, int64(t.Day()), 10)
410 b = append(b, []byte{0x20}...)
411 b = append(b, mas.monthsWide[t.Month()]...)
412 b = append(b, []byte{0x20}...)
413
414 if t.Year() > 0 {
415 b = strconv.AppendInt(b, int64(t.Year()), 10)
416 } else {
417 b = strconv.AppendInt(b, int64(-t.Year()), 10)
418 }
419
420 return string(b)
421 }
422
423
424 func (mas *mas_TZ) FmtTimeShort(t time.Time) string {
425
426 b := make([]byte, 0, 32)
427
428 if t.Hour() < 10 {
429 b = append(b, '0')
430 }
431
432 b = strconv.AppendInt(b, int64(t.Hour()), 10)
433 b = append(b, mas.timeSeparator...)
434
435 if t.Minute() < 10 {
436 b = append(b, '0')
437 }
438
439 b = strconv.AppendInt(b, int64(t.Minute()), 10)
440
441 return string(b)
442 }
443
444
445 func (mas *mas_TZ) FmtTimeMedium(t time.Time) string {
446
447 b := make([]byte, 0, 32)
448
449 if t.Hour() < 10 {
450 b = append(b, '0')
451 }
452
453 b = strconv.AppendInt(b, int64(t.Hour()), 10)
454 b = append(b, mas.timeSeparator...)
455
456 if t.Minute() < 10 {
457 b = append(b, '0')
458 }
459
460 b = strconv.AppendInt(b, int64(t.Minute()), 10)
461 b = append(b, mas.timeSeparator...)
462
463 if t.Second() < 10 {
464 b = append(b, '0')
465 }
466
467 b = strconv.AppendInt(b, int64(t.Second()), 10)
468
469 return string(b)
470 }
471
472
473 func (mas *mas_TZ) FmtTimeLong(t time.Time) string {
474
475 b := make([]byte, 0, 32)
476
477 if t.Hour() < 10 {
478 b = append(b, '0')
479 }
480
481 b = strconv.AppendInt(b, int64(t.Hour()), 10)
482 b = append(b, mas.timeSeparator...)
483
484 if t.Minute() < 10 {
485 b = append(b, '0')
486 }
487
488 b = strconv.AppendInt(b, int64(t.Minute()), 10)
489 b = append(b, mas.timeSeparator...)
490
491 if t.Second() < 10 {
492 b = append(b, '0')
493 }
494
495 b = strconv.AppendInt(b, int64(t.Second()), 10)
496 b = append(b, []byte{0x20}...)
497
498 tz, _ := t.Zone()
499 b = append(b, tz...)
500
501 return string(b)
502 }
503
504
505 func (mas *mas_TZ) FmtTimeFull(t time.Time) string {
506
507 b := make([]byte, 0, 32)
508
509 if t.Hour() < 10 {
510 b = append(b, '0')
511 }
512
513 b = strconv.AppendInt(b, int64(t.Hour()), 10)
514 b = append(b, mas.timeSeparator...)
515
516 if t.Minute() < 10 {
517 b = append(b, '0')
518 }
519
520 b = strconv.AppendInt(b, int64(t.Minute()), 10)
521 b = append(b, mas.timeSeparator...)
522
523 if t.Second() < 10 {
524 b = append(b, '0')
525 }
526
527 b = strconv.AppendInt(b, int64(t.Second()), 10)
528 b = append(b, []byte{0x20}...)
529
530 tz, _ := t.Zone()
531
532 if btz, ok := mas.timezones[tz]; ok {
533 b = append(b, btz...)
534 } else {
535 b = append(b, tz...)
536 }
537
538 return string(b)
539 }
540
View as plain text