1 package mi_NZ
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 mi_NZ 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 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
45 func New() locales.Translator {
46 return &mi_NZ{
47 locale: "mi_NZ",
48 pluralsCardinal: nil,
49 pluralsOrdinal: nil,
50 pluralsRange: nil,
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", "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"},
59 currencyPositivePrefix: " ",
60 currencyNegativePrefix: " ",
61 monthsAbbreviated: []string{"", "Kohi", "Hui", "Pou", "Pae", "Hara", "Pipi", "Hōngo", "Here", "Mahu", "Nuku", "Rangi", "Haki"},
62 monthsNarrow: []string{"", "K", "H", "P", "P", "H", "P", "H", "H", "M", "N", "R", "H"},
63 monthsWide: []string{"", "Kohitātea", "Huitanguru", "Poutūterangi", "Paengawhāwhā", "Haratua", "Pipiri", "Hōngongoi", "Hereturikōkā", "Mahuru", "Whiringa-ā-nuku", "Whiringa-ā-rangi", "Hakihea"},
64 daysAbbreviated: []string{"Tap", "Hin", "Tū", "Apa", "Par", "Mer", "Hor"},
65 daysNarrow: []string{"T", "H", "T", "A", "P", "M", "H"},
66 daysShort: []string{"Tap", "Hin", "Tū", "Apa", "Par", "Mer", "Hor"},
67 daysWide: []string{"Rātapu", "Rāhina", "Rātū", "Rāapa", "Rāpare", "Rāmere", "Rāhoroi"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsNarrow: []string{"AM", "PM"},
70 periodsWide: []string{"AM", "PM"},
71 erasAbbreviated: []string{"BCE", "CE"},
72 erasNarrow: []string{"", ""},
73 erasWide: []string{"BCE", "CE"},
74 timezones: map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "Wā Awatea Ranatiki", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "Wā Arowhānui Ranatiki", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "Wā Awatea Waenga", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "Wā Arowhānui Waenga", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "Wā Awatea Rāwhiti", "EST": "Wā Arowhānui Rāwhiti", "GFT": "GFT", "GMT": "Wā Toharite Greenwich", "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": "Wā Awatea Maunga", "MESZ": "Wā Raumati Uropi Waenga", "MEZ": "Wā Arowhānui Uropi Waenga", "MST": "Wā Arowhānui Maunga", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "Wā Raumati Uropi Rāwhiti", "OEZ": "Wā Arowhānui Uropi Rāwhiti", "PDT": "Wā Awatea Kiwa", "PST": "Wā Arowhānui Kiwa", "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": "Wā Raumati Uropi Uru", "WEZ": "Wā Arowhānui Uropi Uru", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
75 }
76 }
77
78
79 func (mi *mi_NZ) Locale() string {
80 return mi.locale
81 }
82
83
84 func (mi *mi_NZ) PluralsCardinal() []locales.PluralRule {
85 return mi.pluralsCardinal
86 }
87
88
89 func (mi *mi_NZ) PluralsOrdinal() []locales.PluralRule {
90 return mi.pluralsOrdinal
91 }
92
93
94 func (mi *mi_NZ) PluralsRange() []locales.PluralRule {
95 return mi.pluralsRange
96 }
97
98
99 func (mi *mi_NZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
101 }
102
103
104 func (mi *mi_NZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105 return locales.PluralRuleUnknown
106 }
107
108
109 func (mi *mi_NZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
110 return locales.PluralRuleUnknown
111 }
112
113
114 func (mi *mi_NZ) MonthAbbreviated(month time.Month) string {
115 return mi.monthsAbbreviated[month]
116 }
117
118
119 func (mi *mi_NZ) MonthsAbbreviated() []string {
120 return mi.monthsAbbreviated[1:]
121 }
122
123
124 func (mi *mi_NZ) MonthNarrow(month time.Month) string {
125 return mi.monthsNarrow[month]
126 }
127
128
129 func (mi *mi_NZ) MonthsNarrow() []string {
130 return mi.monthsNarrow[1:]
131 }
132
133
134 func (mi *mi_NZ) MonthWide(month time.Month) string {
135 return mi.monthsWide[month]
136 }
137
138
139 func (mi *mi_NZ) MonthsWide() []string {
140 return mi.monthsWide[1:]
141 }
142
143
144 func (mi *mi_NZ) WeekdayAbbreviated(weekday time.Weekday) string {
145 return mi.daysAbbreviated[weekday]
146 }
147
148
149 func (mi *mi_NZ) WeekdaysAbbreviated() []string {
150 return mi.daysAbbreviated
151 }
152
153
154 func (mi *mi_NZ) WeekdayNarrow(weekday time.Weekday) string {
155 return mi.daysNarrow[weekday]
156 }
157
158
159 func (mi *mi_NZ) WeekdaysNarrow() []string {
160 return mi.daysNarrow
161 }
162
163
164 func (mi *mi_NZ) WeekdayShort(weekday time.Weekday) string {
165 return mi.daysShort[weekday]
166 }
167
168
169 func (mi *mi_NZ) WeekdaysShort() []string {
170 return mi.daysShort
171 }
172
173
174 func (mi *mi_NZ) WeekdayWide(weekday time.Weekday) string {
175 return mi.daysWide[weekday]
176 }
177
178
179 func (mi *mi_NZ) WeekdaysWide() []string {
180 return mi.daysWide
181 }
182
183
184 func (mi *mi_NZ) Decimal() string {
185 return mi.decimal
186 }
187
188
189 func (mi *mi_NZ) Group() string {
190 return mi.group
191 }
192
193
194 func (mi *mi_NZ) Minus() string {
195 return mi.minus
196 }
197
198
199 func (mi *mi_NZ) FmtNumber(num float64, v uint64) string {
200
201 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
203 count := 0
204 inWhole := v == 0
205 b := make([]byte, 0, l)
206
207 for i := len(s) - 1; i >= 0; i-- {
208
209 if s[i] == '.' {
210 b = append(b, mi.decimal[0])
211 inWhole = true
212 continue
213 }
214
215 if inWhole {
216 if count == 3 {
217 b = append(b, mi.group[0])
218 count = 1
219 } else {
220 count++
221 }
222 }
223
224 b = append(b, s[i])
225 }
226
227 if num < 0 {
228 b = append(b, mi.minus[0])
229 }
230
231
232 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
233 b[i], b[j] = b[j], b[i]
234 }
235
236 return string(b)
237 }
238
239
240
241 func (mi *mi_NZ) FmtPercent(num float64, v uint64) string {
242 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
243 l := len(s) + 3
244 b := make([]byte, 0, l)
245
246 for i := len(s) - 1; i >= 0; i-- {
247
248 if s[i] == '.' {
249 b = append(b, mi.decimal[0])
250 continue
251 }
252
253 b = append(b, s[i])
254 }
255
256 if num < 0 {
257 b = append(b, mi.minus[0])
258 }
259
260
261 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
262 b[i], b[j] = b[j], b[i]
263 }
264
265 b = append(b, mi.percent...)
266
267 return string(b)
268 }
269
270
271 func (mi *mi_NZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
272
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := mi.currencies[currency]
275 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
276 count := 0
277 inWhole := v == 0
278 b := make([]byte, 0, l)
279
280 for i := len(s) - 1; i >= 0; i-- {
281
282 if s[i] == '.' {
283 b = append(b, mi.decimal[0])
284 inWhole = true
285 continue
286 }
287
288 if inWhole {
289 if count == 3 {
290 b = append(b, mi.group[0])
291 count = 1
292 } else {
293 count++
294 }
295 }
296
297 b = append(b, s[i])
298 }
299
300 for j := len(symbol) - 1; j >= 0; j-- {
301 b = append(b, symbol[j])
302 }
303
304 for j := len(mi.currencyPositivePrefix) - 1; j >= 0; j-- {
305 b = append(b, mi.currencyPositivePrefix[j])
306 }
307
308 if num < 0 {
309 b = append(b, mi.minus[0])
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, mi.decimal...)
321 }
322
323 for i := 0; i < 2-int(v); i++ {
324 b = append(b, '0')
325 }
326 }
327
328 return string(b)
329 }
330
331
332
333 func (mi *mi_NZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
334
335 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
336 symbol := mi.currencies[currency]
337 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
338 count := 0
339 inWhole := v == 0
340 b := make([]byte, 0, l)
341
342 for i := len(s) - 1; i >= 0; i-- {
343
344 if s[i] == '.' {
345 b = append(b, mi.decimal[0])
346 inWhole = true
347 continue
348 }
349
350 if inWhole {
351 if count == 3 {
352 b = append(b, mi.group[0])
353 count = 1
354 } else {
355 count++
356 }
357 }
358
359 b = append(b, s[i])
360 }
361
362 if num < 0 {
363
364 for j := len(symbol) - 1; j >= 0; j-- {
365 b = append(b, symbol[j])
366 }
367
368 for j := len(mi.currencyNegativePrefix) - 1; j >= 0; j-- {
369 b = append(b, mi.currencyNegativePrefix[j])
370 }
371
372 b = append(b, mi.minus[0])
373
374 } else {
375
376 for j := len(symbol) - 1; j >= 0; j-- {
377 b = append(b, symbol[j])
378 }
379
380 for j := len(mi.currencyPositivePrefix) - 1; j >= 0; j-- {
381 b = append(b, mi.currencyPositivePrefix[j])
382 }
383
384 }
385
386
387 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
388 b[i], b[j] = b[j], b[i]
389 }
390
391 if int(v) < 2 {
392
393 if v == 0 {
394 b = append(b, mi.decimal...)
395 }
396
397 for i := 0; i < 2-int(v); i++ {
398 b = append(b, '0')
399 }
400 }
401
402 return string(b)
403 }
404
405
406 func (mi *mi_NZ) FmtDateShort(t time.Time) string {
407
408 b := make([]byte, 0, 32)
409
410 if t.Day() < 10 {
411 b = append(b, '0')
412 }
413
414 b = strconv.AppendInt(b, int64(t.Day()), 10)
415 b = append(b, []byte{0x2d}...)
416
417 if t.Month() < 10 {
418 b = append(b, '0')
419 }
420
421 b = strconv.AppendInt(b, int64(t.Month()), 10)
422
423 b = append(b, []byte{0x2d}...)
424
425 if t.Year() > 0 {
426 b = strconv.AppendInt(b, int64(t.Year()), 10)
427 } else {
428 b = strconv.AppendInt(b, int64(-t.Year()), 10)
429 }
430
431 return string(b)
432 }
433
434
435 func (mi *mi_NZ) FmtDateMedium(t time.Time) string {
436
437 b := make([]byte, 0, 32)
438
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x20}...)
441 b = append(b, mi.monthsAbbreviated[t.Month()]...)
442 b = append(b, []byte{0x20}...)
443
444 if t.Year() > 0 {
445 b = strconv.AppendInt(b, int64(t.Year()), 10)
446 } else {
447 b = strconv.AppendInt(b, int64(-t.Year()), 10)
448 }
449
450 return string(b)
451 }
452
453
454 func (mi *mi_NZ) FmtDateLong(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 b = strconv.AppendInt(b, int64(t.Day()), 10)
459 b = append(b, []byte{0x20}...)
460 b = append(b, mi.monthsWide[t.Month()]...)
461 b = append(b, []byte{0x20}...)
462
463 if t.Year() > 0 {
464 b = strconv.AppendInt(b, int64(t.Year()), 10)
465 } else {
466 b = strconv.AppendInt(b, int64(-t.Year()), 10)
467 }
468
469 return string(b)
470 }
471
472
473 func (mi *mi_NZ) FmtDateFull(t time.Time) string {
474
475 b := make([]byte, 0, 32)
476
477 b = append(b, mi.daysWide[t.Weekday()]...)
478 b = append(b, []byte{0x2c, 0x20}...)
479 b = strconv.AppendInt(b, int64(t.Day()), 10)
480 b = append(b, []byte{0x20}...)
481 b = append(b, mi.monthsWide[t.Month()]...)
482 b = append(b, []byte{0x20}...)
483
484 if t.Year() > 0 {
485 b = strconv.AppendInt(b, int64(t.Year()), 10)
486 } else {
487 b = strconv.AppendInt(b, int64(-t.Year()), 10)
488 }
489
490 return string(b)
491 }
492
493
494 func (mi *mi_NZ) FmtTimeShort(t time.Time) string {
495
496 b := make([]byte, 0, 32)
497
498 h := t.Hour()
499
500 if h > 12 {
501 h -= 12
502 }
503
504 b = strconv.AppendInt(b, int64(h), 10)
505 b = append(b, mi.timeSeparator...)
506
507 if t.Minute() < 10 {
508 b = append(b, '0')
509 }
510
511 b = strconv.AppendInt(b, int64(t.Minute()), 10)
512 b = append(b, []byte{0x20}...)
513
514 if t.Hour() < 12 {
515 b = append(b, mi.periodsAbbreviated[0]...)
516 } else {
517 b = append(b, mi.periodsAbbreviated[1]...)
518 }
519
520 return string(b)
521 }
522
523
524 func (mi *mi_NZ) FmtTimeMedium(t time.Time) string {
525
526 b := make([]byte, 0, 32)
527
528 h := t.Hour()
529
530 if h > 12 {
531 h -= 12
532 }
533
534 b = strconv.AppendInt(b, int64(h), 10)
535 b = append(b, mi.timeSeparator...)
536
537 if t.Minute() < 10 {
538 b = append(b, '0')
539 }
540
541 b = strconv.AppendInt(b, int64(t.Minute()), 10)
542 b = append(b, mi.timeSeparator...)
543
544 if t.Second() < 10 {
545 b = append(b, '0')
546 }
547
548 b = strconv.AppendInt(b, int64(t.Second()), 10)
549 b = append(b, []byte{0x20}...)
550
551 if t.Hour() < 12 {
552 b = append(b, mi.periodsAbbreviated[0]...)
553 } else {
554 b = append(b, mi.periodsAbbreviated[1]...)
555 }
556
557 return string(b)
558 }
559
560
561 func (mi *mi_NZ) FmtTimeLong(t time.Time) string {
562
563 b := make([]byte, 0, 32)
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, mi.timeSeparator...)
573
574 if t.Minute() < 10 {
575 b = append(b, '0')
576 }
577
578 b = strconv.AppendInt(b, int64(t.Minute()), 10)
579 b = append(b, mi.timeSeparator...)
580
581 if t.Second() < 10 {
582 b = append(b, '0')
583 }
584
585 b = strconv.AppendInt(b, int64(t.Second()), 10)
586 b = append(b, []byte{0x20}...)
587
588 if t.Hour() < 12 {
589 b = append(b, mi.periodsAbbreviated[0]...)
590 } else {
591 b = append(b, mi.periodsAbbreviated[1]...)
592 }
593
594 b = append(b, []byte{0x20}...)
595
596 tz, _ := t.Zone()
597 b = append(b, tz...)
598
599 return string(b)
600 }
601
602
603 func (mi *mi_NZ) FmtTimeFull(t time.Time) string {
604
605 b := make([]byte, 0, 32)
606
607 h := t.Hour()
608
609 if h > 12 {
610 h -= 12
611 }
612
613 b = strconv.AppendInt(b, int64(h), 10)
614 b = append(b, mi.timeSeparator...)
615
616 if t.Minute() < 10 {
617 b = append(b, '0')
618 }
619
620 b = strconv.AppendInt(b, int64(t.Minute()), 10)
621 b = append(b, mi.timeSeparator...)
622
623 if t.Second() < 10 {
624 b = append(b, '0')
625 }
626
627 b = strconv.AppendInt(b, int64(t.Second()), 10)
628 b = append(b, []byte{0x20}...)
629
630 if t.Hour() < 12 {
631 b = append(b, mi.periodsAbbreviated[0]...)
632 } else {
633 b = append(b, mi.periodsAbbreviated[1]...)
634 }
635
636 b = append(b, []byte{0x20}...)
637
638 tz, _ := t.Zone()
639
640 if btz, ok := mi.timezones[tz]; ok {
641 b = append(b, btz...)
642 } else {
643 b = append(b, tz...)
644 }
645
646 return string(b)
647 }
648
View as plain text