1 package rwk_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 rwk_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 monthsAbbreviated []string
26 monthsNarrow []string
27 monthsWide []string
28 daysAbbreviated []string
29 daysNarrow []string
30 daysShort []string
31 daysWide []string
32 periodsAbbreviated []string
33 periodsNarrow []string
34 periodsShort []string
35 periodsWide []string
36 erasAbbreviated []string
37 erasNarrow []string
38 erasWide []string
39 timezones map[string]string
40 }
41
42
43 func New() locales.Translator {
44 return &rwk_TZ{
45 locale: "rwk_TZ",
46 pluralsCardinal: []locales.PluralRule{2, 6},
47 pluralsOrdinal: nil,
48 pluralsRange: nil,
49 timeSeparator: ":",
50 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"},
51 monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"},
52 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
53 monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"},
54 daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"},
55 daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"},
56 daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"},
57 periodsAbbreviated: []string{"utuko", "kyiukonyi"},
58 periodsWide: []string{"utuko", "kyiukonyi"},
59 erasAbbreviated: []string{"KK", "BK"},
60 erasNarrow: []string{"", ""},
61 erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"},
62 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", "∅∅∅": "∅∅∅"},
63 }
64 }
65
66
67 func (rwk *rwk_TZ) Locale() string {
68 return rwk.locale
69 }
70
71
72 func (rwk *rwk_TZ) PluralsCardinal() []locales.PluralRule {
73 return rwk.pluralsCardinal
74 }
75
76
77 func (rwk *rwk_TZ) PluralsOrdinal() []locales.PluralRule {
78 return rwk.pluralsOrdinal
79 }
80
81
82 func (rwk *rwk_TZ) PluralsRange() []locales.PluralRule {
83 return rwk.pluralsRange
84 }
85
86
87 func (rwk *rwk_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
88
89 n := math.Abs(num)
90
91 if n == 1 {
92 return locales.PluralRuleOne
93 }
94
95 return locales.PluralRuleOther
96 }
97
98
99 func (rwk *rwk_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
101 }
102
103
104 func (rwk *rwk_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
105 return locales.PluralRuleUnknown
106 }
107
108
109 func (rwk *rwk_TZ) MonthAbbreviated(month time.Month) string {
110 return rwk.monthsAbbreviated[month]
111 }
112
113
114 func (rwk *rwk_TZ) MonthsAbbreviated() []string {
115 return rwk.monthsAbbreviated[1:]
116 }
117
118
119 func (rwk *rwk_TZ) MonthNarrow(month time.Month) string {
120 return rwk.monthsNarrow[month]
121 }
122
123
124 func (rwk *rwk_TZ) MonthsNarrow() []string {
125 return rwk.monthsNarrow[1:]
126 }
127
128
129 func (rwk *rwk_TZ) MonthWide(month time.Month) string {
130 return rwk.monthsWide[month]
131 }
132
133
134 func (rwk *rwk_TZ) MonthsWide() []string {
135 return rwk.monthsWide[1:]
136 }
137
138
139 func (rwk *rwk_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
140 return rwk.daysAbbreviated[weekday]
141 }
142
143
144 func (rwk *rwk_TZ) WeekdaysAbbreviated() []string {
145 return rwk.daysAbbreviated
146 }
147
148
149 func (rwk *rwk_TZ) WeekdayNarrow(weekday time.Weekday) string {
150 return rwk.daysNarrow[weekday]
151 }
152
153
154 func (rwk *rwk_TZ) WeekdaysNarrow() []string {
155 return rwk.daysNarrow
156 }
157
158
159 func (rwk *rwk_TZ) WeekdayShort(weekday time.Weekday) string {
160 return rwk.daysShort[weekday]
161 }
162
163
164 func (rwk *rwk_TZ) WeekdaysShort() []string {
165 return rwk.daysShort
166 }
167
168
169 func (rwk *rwk_TZ) WeekdayWide(weekday time.Weekday) string {
170 return rwk.daysWide[weekday]
171 }
172
173
174 func (rwk *rwk_TZ) WeekdaysWide() []string {
175 return rwk.daysWide
176 }
177
178
179 func (rwk *rwk_TZ) Decimal() string {
180 return rwk.decimal
181 }
182
183
184 func (rwk *rwk_TZ) Group() string {
185 return rwk.group
186 }
187
188
189 func (rwk *rwk_TZ) Minus() string {
190 return rwk.minus
191 }
192
193
194 func (rwk *rwk_TZ) FmtNumber(num float64, v uint64) string {
195
196 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
197 }
198
199
200
201 func (rwk *rwk_TZ) FmtPercent(num float64, v uint64) string {
202 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
203 }
204
205
206 func (rwk *rwk_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
207
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 symbol := rwk.currencies[currency]
210 l := len(s) + len(symbol) + 0
211 count := 0
212 inWhole := v == 0
213 b := make([]byte, 0, l)
214
215 for i := len(s) - 1; i >= 0; i-- {
216
217 if s[i] == '.' {
218 b = append(b, rwk.decimal[0])
219 inWhole = true
220 continue
221 }
222
223 if inWhole {
224 if count == 3 {
225 b = append(b, rwk.group[0])
226 count = 1
227 } else {
228 count++
229 }
230 }
231
232 b = append(b, s[i])
233 }
234
235 if num < 0 {
236 b = append(b, rwk.minus[0])
237 }
238
239
240 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
241 b[i], b[j] = b[j], b[i]
242 }
243
244 if int(v) < 2 {
245
246 if v == 0 {
247 b = append(b, rwk.decimal...)
248 }
249
250 for i := 0; i < 2-int(v); i++ {
251 b = append(b, '0')
252 }
253 }
254
255 b = append(b, symbol...)
256
257 return string(b)
258 }
259
260
261
262 func (rwk *rwk_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
263
264 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 symbol := rwk.currencies[currency]
266 l := len(s) + len(symbol) + 0
267 count := 0
268 inWhole := v == 0
269 b := make([]byte, 0, l)
270
271 for i := len(s) - 1; i >= 0; i-- {
272
273 if s[i] == '.' {
274 b = append(b, rwk.decimal[0])
275 inWhole = true
276 continue
277 }
278
279 if inWhole {
280 if count == 3 {
281 b = append(b, rwk.group[0])
282 count = 1
283 } else {
284 count++
285 }
286 }
287
288 b = append(b, s[i])
289 }
290
291 if num < 0 {
292
293 b = append(b, rwk.minus[0])
294
295 }
296
297
298 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
299 b[i], b[j] = b[j], b[i]
300 }
301
302 if int(v) < 2 {
303
304 if v == 0 {
305 b = append(b, rwk.decimal...)
306 }
307
308 for i := 0; i < 2-int(v); i++ {
309 b = append(b, '0')
310 }
311 }
312
313 if num < 0 {
314 b = append(b, symbol...)
315 } else {
316
317 b = append(b, symbol...)
318 }
319
320 return string(b)
321 }
322
323
324 func (rwk *rwk_TZ) FmtDateShort(t time.Time) string {
325
326 b := make([]byte, 0, 32)
327
328 if t.Day() < 10 {
329 b = append(b, '0')
330 }
331
332 b = strconv.AppendInt(b, int64(t.Day()), 10)
333 b = append(b, []byte{0x2f}...)
334
335 if t.Month() < 10 {
336 b = append(b, '0')
337 }
338
339 b = strconv.AppendInt(b, int64(t.Month()), 10)
340
341 b = append(b, []byte{0x2f}...)
342
343 if t.Year() > 0 {
344 b = strconv.AppendInt(b, int64(t.Year()), 10)
345 } else {
346 b = strconv.AppendInt(b, int64(-t.Year()), 10)
347 }
348
349 return string(b)
350 }
351
352
353 func (rwk *rwk_TZ) FmtDateMedium(t time.Time) string {
354
355 b := make([]byte, 0, 32)
356
357 b = strconv.AppendInt(b, int64(t.Day()), 10)
358 b = append(b, []byte{0x20}...)
359 b = append(b, rwk.monthsAbbreviated[t.Month()]...)
360 b = append(b, []byte{0x20}...)
361
362 if t.Year() > 0 {
363 b = strconv.AppendInt(b, int64(t.Year()), 10)
364 } else {
365 b = strconv.AppendInt(b, int64(-t.Year()), 10)
366 }
367
368 return string(b)
369 }
370
371
372 func (rwk *rwk_TZ) FmtDateLong(t time.Time) string {
373
374 b := make([]byte, 0, 32)
375
376 b = strconv.AppendInt(b, int64(t.Day()), 10)
377 b = append(b, []byte{0x20}...)
378 b = append(b, rwk.monthsWide[t.Month()]...)
379 b = append(b, []byte{0x20}...)
380
381 if t.Year() > 0 {
382 b = strconv.AppendInt(b, int64(t.Year()), 10)
383 } else {
384 b = strconv.AppendInt(b, int64(-t.Year()), 10)
385 }
386
387 return string(b)
388 }
389
390
391 func (rwk *rwk_TZ) FmtDateFull(t time.Time) string {
392
393 b := make([]byte, 0, 32)
394
395 b = append(b, rwk.daysWide[t.Weekday()]...)
396 b = append(b, []byte{0x2c, 0x20}...)
397 b = strconv.AppendInt(b, int64(t.Day()), 10)
398 b = append(b, []byte{0x20}...)
399 b = append(b, rwk.monthsWide[t.Month()]...)
400 b = append(b, []byte{0x20}...)
401
402 if t.Year() > 0 {
403 b = strconv.AppendInt(b, int64(t.Year()), 10)
404 } else {
405 b = strconv.AppendInt(b, int64(-t.Year()), 10)
406 }
407
408 return string(b)
409 }
410
411
412 func (rwk *rwk_TZ) FmtTimeShort(t time.Time) string {
413
414 b := make([]byte, 0, 32)
415
416 if t.Hour() < 10 {
417 b = append(b, '0')
418 }
419
420 b = strconv.AppendInt(b, int64(t.Hour()), 10)
421 b = append(b, rwk.timeSeparator...)
422
423 if t.Minute() < 10 {
424 b = append(b, '0')
425 }
426
427 b = strconv.AppendInt(b, int64(t.Minute()), 10)
428
429 return string(b)
430 }
431
432
433 func (rwk *rwk_TZ) FmtTimeMedium(t time.Time) string {
434
435 b := make([]byte, 0, 32)
436
437 if t.Hour() < 10 {
438 b = append(b, '0')
439 }
440
441 b = strconv.AppendInt(b, int64(t.Hour()), 10)
442 b = append(b, rwk.timeSeparator...)
443
444 if t.Minute() < 10 {
445 b = append(b, '0')
446 }
447
448 b = strconv.AppendInt(b, int64(t.Minute()), 10)
449 b = append(b, rwk.timeSeparator...)
450
451 if t.Second() < 10 {
452 b = append(b, '0')
453 }
454
455 b = strconv.AppendInt(b, int64(t.Second()), 10)
456
457 return string(b)
458 }
459
460
461 func (rwk *rwk_TZ) FmtTimeLong(t time.Time) string {
462
463 b := make([]byte, 0, 32)
464
465 if t.Hour() < 10 {
466 b = append(b, '0')
467 }
468
469 b = strconv.AppendInt(b, int64(t.Hour()), 10)
470 b = append(b, rwk.timeSeparator...)
471
472 if t.Minute() < 10 {
473 b = append(b, '0')
474 }
475
476 b = strconv.AppendInt(b, int64(t.Minute()), 10)
477 b = append(b, rwk.timeSeparator...)
478
479 if t.Second() < 10 {
480 b = append(b, '0')
481 }
482
483 b = strconv.AppendInt(b, int64(t.Second()), 10)
484 b = append(b, []byte{0x20}...)
485
486 tz, _ := t.Zone()
487 b = append(b, tz...)
488
489 return string(b)
490 }
491
492
493 func (rwk *rwk_TZ) FmtTimeFull(t time.Time) string {
494
495 b := make([]byte, 0, 32)
496
497 if t.Hour() < 10 {
498 b = append(b, '0')
499 }
500
501 b = strconv.AppendInt(b, int64(t.Hour()), 10)
502 b = append(b, rwk.timeSeparator...)
503
504 if t.Minute() < 10 {
505 b = append(b, '0')
506 }
507
508 b = strconv.AppendInt(b, int64(t.Minute()), 10)
509 b = append(b, rwk.timeSeparator...)
510
511 if t.Second() < 10 {
512 b = append(b, '0')
513 }
514
515 b = strconv.AppendInt(b, int64(t.Second()), 10)
516 b = append(b, []byte{0x20}...)
517
518 tz, _ := t.Zone()
519
520 if btz, ok := rwk.timezones[tz]; ok {
521 b = append(b, btz...)
522 } else {
523 b = append(b, tz...)
524 }
525
526 return string(b)
527 }
528
View as plain text