1 package lag_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 lag_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 currencyPositivePrefix string
26 currencyPositiveSuffix string
27 currencyNegativePrefix string
28 currencyNegativeSuffix string
29 monthsAbbreviated []string
30 monthsNarrow []string
31 monthsWide []string
32 daysAbbreviated []string
33 daysNarrow []string
34 daysShort []string
35 daysWide []string
36 periodsAbbreviated []string
37 periodsNarrow []string
38 periodsShort []string
39 periodsWide []string
40 erasAbbreviated []string
41 erasNarrow []string
42 erasWide []string
43 timezones map[string]string
44 }
45
46
47 func New() locales.Translator {
48 return &lag_TZ{
49 locale: "lag_TZ",
50 pluralsCardinal: []locales.PluralRule{1, 2, 6},
51 pluralsOrdinal: nil,
52 pluralsRange: nil,
53 timeSeparator: ":",
54 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", "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"},
55 currencyPositivePrefix: " ",
56 currencyPositiveSuffix: "K",
57 currencyNegativePrefix: " ",
58 currencyNegativeSuffix: "K",
59 monthsAbbreviated: []string{"", "Fúngatɨ", "Naanɨ", "Keenda", "Ikúmi", "Inyambala", "Idwaata", "Mʉʉnchɨ", "Vɨɨrɨ", "Saatʉ", "Inyi", "Saano", "Sasatʉ"},
60 monthsNarrow: []string{"", "F", "N", "K", "I", "I", "I", "M", "V", "S", "I", "S", "S"},
61 monthsWide: []string{"", "Kʉfúngatɨ", "Kʉnaanɨ", "Kʉkeenda", "Kwiikumi", "Kwiinyambála", "Kwiidwaata", "Kʉmʉʉnchɨ", "Kʉvɨɨrɨ", "Kʉsaatʉ", "Kwiinyi", "Kʉsaano", "Kʉsasatʉ"},
62 daysAbbreviated: []string{"Píili", "Táatu", "Íne", "Táano", "Alh", "Ijm", "Móosi"},
63 daysNarrow: []string{"P", "T", "E", "O", "A", "I", "M"},
64 daysWide: []string{"Jumapíiri", "Jumatátu", "Jumaíne", "Jumatáano", "Alamíisi", "Ijumáa", "Jumamóosi"},
65 periodsAbbreviated: []string{"TOO", "MUU"},
66 periodsWide: []string{"TOO", "MUU"},
67 erasAbbreviated: []string{"KSA", "KA"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"Kɨrɨsitʉ sɨ anavyaal", "Kɨrɨsitʉ akavyaalwe"},
70 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", "∅∅∅": "∅∅∅"},
71 }
72 }
73
74
75 func (lag *lag_TZ) Locale() string {
76 return lag.locale
77 }
78
79
80 func (lag *lag_TZ) PluralsCardinal() []locales.PluralRule {
81 return lag.pluralsCardinal
82 }
83
84
85 func (lag *lag_TZ) PluralsOrdinal() []locales.PluralRule {
86 return lag.pluralsOrdinal
87 }
88
89
90 func (lag *lag_TZ) PluralsRange() []locales.PluralRule {
91 return lag.pluralsRange
92 }
93
94
95 func (lag *lag_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97 n := math.Abs(num)
98 i := int64(n)
99
100 if n == 0 {
101 return locales.PluralRuleZero
102 } else if (i == 0 || i == 1) && n != 0 {
103 return locales.PluralRuleOne
104 }
105
106 return locales.PluralRuleOther
107 }
108
109
110 func (lag *lag_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
111 return locales.PluralRuleUnknown
112 }
113
114
115 func (lag *lag_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
116 return locales.PluralRuleUnknown
117 }
118
119
120 func (lag *lag_TZ) MonthAbbreviated(month time.Month) string {
121 return lag.monthsAbbreviated[month]
122 }
123
124
125 func (lag *lag_TZ) MonthsAbbreviated() []string {
126 return lag.monthsAbbreviated[1:]
127 }
128
129
130 func (lag *lag_TZ) MonthNarrow(month time.Month) string {
131 return lag.monthsNarrow[month]
132 }
133
134
135 func (lag *lag_TZ) MonthsNarrow() []string {
136 return lag.monthsNarrow[1:]
137 }
138
139
140 func (lag *lag_TZ) MonthWide(month time.Month) string {
141 return lag.monthsWide[month]
142 }
143
144
145 func (lag *lag_TZ) MonthsWide() []string {
146 return lag.monthsWide[1:]
147 }
148
149
150 func (lag *lag_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
151 return lag.daysAbbreviated[weekday]
152 }
153
154
155 func (lag *lag_TZ) WeekdaysAbbreviated() []string {
156 return lag.daysAbbreviated
157 }
158
159
160 func (lag *lag_TZ) WeekdayNarrow(weekday time.Weekday) string {
161 return lag.daysNarrow[weekday]
162 }
163
164
165 func (lag *lag_TZ) WeekdaysNarrow() []string {
166 return lag.daysNarrow
167 }
168
169
170 func (lag *lag_TZ) WeekdayShort(weekday time.Weekday) string {
171 return lag.daysShort[weekday]
172 }
173
174
175 func (lag *lag_TZ) WeekdaysShort() []string {
176 return lag.daysShort
177 }
178
179
180 func (lag *lag_TZ) WeekdayWide(weekday time.Weekday) string {
181 return lag.daysWide[weekday]
182 }
183
184
185 func (lag *lag_TZ) WeekdaysWide() []string {
186 return lag.daysWide
187 }
188
189
190 func (lag *lag_TZ) Decimal() string {
191 return lag.decimal
192 }
193
194
195 func (lag *lag_TZ) Group() string {
196 return lag.group
197 }
198
199
200 func (lag *lag_TZ) Minus() string {
201 return lag.minus
202 }
203
204
205 func (lag *lag_TZ) FmtNumber(num float64, v uint64) string {
206
207 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
208 }
209
210
211
212 func (lag *lag_TZ) FmtPercent(num float64, v uint64) string {
213 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
214 }
215
216
217 func (lag *lag_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
218
219 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
220 symbol := lag.currencies[currency]
221 l := len(s) + len(symbol) + 3
222
223 b := make([]byte, 0, l)
224
225 for i := len(s) - 1; i >= 0; i-- {
226
227 if s[i] == '.' {
228 b = append(b, lag.decimal[0])
229 continue
230 }
231
232 b = append(b, s[i])
233 }
234
235 for j := len(symbol) - 1; j >= 0; j-- {
236 b = append(b, symbol[j])
237 }
238
239 for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- {
240 b = append(b, lag.currencyPositivePrefix[j])
241 }
242
243 if num < 0 {
244 b = append(b, lag.minus[0])
245 }
246
247
248 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
249 b[i], b[j] = b[j], b[i]
250 }
251
252 b = append(b, lag.currencyPositiveSuffix...)
253
254 return string(b)
255 }
256
257
258
259 func (lag *lag_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
260
261 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
262 symbol := lag.currencies[currency]
263 l := len(s) + len(symbol) + 3
264
265 b := make([]byte, 0, l)
266
267 for i := len(s) - 1; i >= 0; i-- {
268
269 if s[i] == '.' {
270 b = append(b, lag.decimal[0])
271 continue
272 }
273
274 b = append(b, s[i])
275 }
276
277 if num < 0 {
278
279 for j := len(symbol) - 1; j >= 0; j-- {
280 b = append(b, symbol[j])
281 }
282
283 for j := len(lag.currencyNegativePrefix) - 1; j >= 0; j-- {
284 b = append(b, lag.currencyNegativePrefix[j])
285 }
286
287 b = append(b, lag.minus[0])
288
289 } else {
290
291 for j := len(symbol) - 1; j >= 0; j-- {
292 b = append(b, symbol[j])
293 }
294
295 for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- {
296 b = append(b, lag.currencyPositivePrefix[j])
297 }
298
299 }
300
301
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 if num < 0 {
307 b = append(b, lag.currencyNegativeSuffix...)
308 } else {
309
310 b = append(b, lag.currencyPositiveSuffix...)
311 }
312
313 return string(b)
314 }
315
316
317 func (lag *lag_TZ) FmtDateShort(t time.Time) string {
318
319 b := make([]byte, 0, 32)
320
321 if t.Day() < 10 {
322 b = append(b, '0')
323 }
324
325 b = strconv.AppendInt(b, int64(t.Day()), 10)
326 b = append(b, []byte{0x2f}...)
327
328 if t.Month() < 10 {
329 b = append(b, '0')
330 }
331
332 b = strconv.AppendInt(b, int64(t.Month()), 10)
333
334 b = append(b, []byte{0x2f}...)
335
336 if t.Year() > 0 {
337 b = strconv.AppendInt(b, int64(t.Year()), 10)
338 } else {
339 b = strconv.AppendInt(b, int64(-t.Year()), 10)
340 }
341
342 return string(b)
343 }
344
345
346 func (lag *lag_TZ) FmtDateMedium(t time.Time) string {
347
348 b := make([]byte, 0, 32)
349
350 b = strconv.AppendInt(b, int64(t.Day()), 10)
351 b = append(b, []byte{0x20}...)
352 b = append(b, lag.monthsAbbreviated[t.Month()]...)
353 b = append(b, []byte{0x20}...)
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 (lag *lag_TZ) FmtDateLong(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, lag.monthsWide[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 (lag *lag_TZ) FmtDateFull(t time.Time) string {
385
386 b := make([]byte, 0, 32)
387
388 b = append(b, lag.daysWide[t.Weekday()]...)
389 b = append(b, []byte{0x2c, 0x20}...)
390 b = strconv.AppendInt(b, int64(t.Day()), 10)
391 b = append(b, []byte{0x20}...)
392 b = append(b, lag.monthsWide[t.Month()]...)
393 b = append(b, []byte{0x20}...)
394
395 if t.Year() > 0 {
396 b = strconv.AppendInt(b, int64(t.Year()), 10)
397 } else {
398 b = strconv.AppendInt(b, int64(-t.Year()), 10)
399 }
400
401 return string(b)
402 }
403
404
405 func (lag *lag_TZ) FmtTimeShort(t time.Time) string {
406
407 b := make([]byte, 0, 32)
408
409 if t.Hour() < 10 {
410 b = append(b, '0')
411 }
412
413 b = strconv.AppendInt(b, int64(t.Hour()), 10)
414 b = append(b, lag.timeSeparator...)
415
416 if t.Minute() < 10 {
417 b = append(b, '0')
418 }
419
420 b = strconv.AppendInt(b, int64(t.Minute()), 10)
421
422 return string(b)
423 }
424
425
426 func (lag *lag_TZ) FmtTimeMedium(t time.Time) string {
427
428 b := make([]byte, 0, 32)
429
430 if t.Hour() < 10 {
431 b = append(b, '0')
432 }
433
434 b = strconv.AppendInt(b, int64(t.Hour()), 10)
435 b = append(b, lag.timeSeparator...)
436
437 if t.Minute() < 10 {
438 b = append(b, '0')
439 }
440
441 b = strconv.AppendInt(b, int64(t.Minute()), 10)
442 b = append(b, lag.timeSeparator...)
443
444 if t.Second() < 10 {
445 b = append(b, '0')
446 }
447
448 b = strconv.AppendInt(b, int64(t.Second()), 10)
449
450 return string(b)
451 }
452
453
454 func (lag *lag_TZ) FmtTimeLong(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 if t.Hour() < 10 {
459 b = append(b, '0')
460 }
461
462 b = strconv.AppendInt(b, int64(t.Hour()), 10)
463 b = append(b, lag.timeSeparator...)
464
465 if t.Minute() < 10 {
466 b = append(b, '0')
467 }
468
469 b = strconv.AppendInt(b, int64(t.Minute()), 10)
470 b = append(b, lag.timeSeparator...)
471
472 if t.Second() < 10 {
473 b = append(b, '0')
474 }
475
476 b = strconv.AppendInt(b, int64(t.Second()), 10)
477 b = append(b, []byte{0x20}...)
478
479 tz, _ := t.Zone()
480 b = append(b, tz...)
481
482 return string(b)
483 }
484
485
486 func (lag *lag_TZ) FmtTimeFull(t time.Time) string {
487
488 b := make([]byte, 0, 32)
489
490 if t.Hour() < 10 {
491 b = append(b, '0')
492 }
493
494 b = strconv.AppendInt(b, int64(t.Hour()), 10)
495 b = append(b, lag.timeSeparator...)
496
497 if t.Minute() < 10 {
498 b = append(b, '0')
499 }
500
501 b = strconv.AppendInt(b, int64(t.Minute()), 10)
502 b = append(b, lag.timeSeparator...)
503
504 if t.Second() < 10 {
505 b = append(b, '0')
506 }
507
508 b = strconv.AppendInt(b, int64(t.Second()), 10)
509 b = append(b, []byte{0x20}...)
510
511 tz, _ := t.Zone()
512
513 if btz, ok := lag.timezones[tz]; ok {
514 b = append(b, btz...)
515 } else {
516 b = append(b, tz...)
517 }
518
519 return string(b)
520 }
521
View as plain text