1 package haw_US
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 haw_US 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 &haw_US{
47 locale: "haw_US",
48 pluralsCardinal: []locales.PluralRule{2, 6},
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 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "Ian.", "Pep.", "Mal.", "ʻAp.", "Mei", "Iun.", "Iul.", "ʻAu.", "Kep.", "ʻOk.", "Now.", "Kek."},
62 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
63 monthsWide: []string{"", "Ianuali", "Pepeluali", "Malaki", "ʻApelila", "Mei", "Iune", "Iulai", "ʻAukake", "Kepakemapa", "ʻOkakopa", "Nowemapa", "Kekemapa"},
64 daysAbbreviated: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"},
65 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
66 daysShort: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"},
67 daysWide: []string{"Lāpule", "Poʻakahi", "Poʻalua", "Poʻakolu", "Poʻahā", "Poʻalima", "Poʻaono"},
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": "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", "∅∅∅": "∅∅∅"},
75 }
76 }
77
78
79 func (haw *haw_US) Locale() string {
80 return haw.locale
81 }
82
83
84 func (haw *haw_US) PluralsCardinal() []locales.PluralRule {
85 return haw.pluralsCardinal
86 }
87
88
89 func (haw *haw_US) PluralsOrdinal() []locales.PluralRule {
90 return haw.pluralsOrdinal
91 }
92
93
94 func (haw *haw_US) PluralsRange() []locales.PluralRule {
95 return haw.pluralsRange
96 }
97
98
99 func (haw *haw_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101 n := math.Abs(num)
102
103 if n == 1 {
104 return locales.PluralRuleOne
105 }
106
107 return locales.PluralRuleOther
108 }
109
110
111 func (haw *haw_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
112 return locales.PluralRuleUnknown
113 }
114
115
116 func (haw *haw_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
117 return locales.PluralRuleUnknown
118 }
119
120
121 func (haw *haw_US) MonthAbbreviated(month time.Month) string {
122 return haw.monthsAbbreviated[month]
123 }
124
125
126 func (haw *haw_US) MonthsAbbreviated() []string {
127 return haw.monthsAbbreviated[1:]
128 }
129
130
131 func (haw *haw_US) MonthNarrow(month time.Month) string {
132 return haw.monthsNarrow[month]
133 }
134
135
136 func (haw *haw_US) MonthsNarrow() []string {
137 return haw.monthsNarrow[1:]
138 }
139
140
141 func (haw *haw_US) MonthWide(month time.Month) string {
142 return haw.monthsWide[month]
143 }
144
145
146 func (haw *haw_US) MonthsWide() []string {
147 return haw.monthsWide[1:]
148 }
149
150
151 func (haw *haw_US) WeekdayAbbreviated(weekday time.Weekday) string {
152 return haw.daysAbbreviated[weekday]
153 }
154
155
156 func (haw *haw_US) WeekdaysAbbreviated() []string {
157 return haw.daysAbbreviated
158 }
159
160
161 func (haw *haw_US) WeekdayNarrow(weekday time.Weekday) string {
162 return haw.daysNarrow[weekday]
163 }
164
165
166 func (haw *haw_US) WeekdaysNarrow() []string {
167 return haw.daysNarrow
168 }
169
170
171 func (haw *haw_US) WeekdayShort(weekday time.Weekday) string {
172 return haw.daysShort[weekday]
173 }
174
175
176 func (haw *haw_US) WeekdaysShort() []string {
177 return haw.daysShort
178 }
179
180
181 func (haw *haw_US) WeekdayWide(weekday time.Weekday) string {
182 return haw.daysWide[weekday]
183 }
184
185
186 func (haw *haw_US) WeekdaysWide() []string {
187 return haw.daysWide
188 }
189
190
191 func (haw *haw_US) Decimal() string {
192 return haw.decimal
193 }
194
195
196 func (haw *haw_US) Group() string {
197 return haw.group
198 }
199
200
201 func (haw *haw_US) Minus() string {
202 return haw.minus
203 }
204
205
206 func (haw *haw_US) FmtNumber(num float64, v uint64) string {
207
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
210 count := 0
211 inWhole := v == 0
212 b := make([]byte, 0, l)
213
214 for i := len(s) - 1; i >= 0; i-- {
215
216 if s[i] == '.' {
217 b = append(b, haw.decimal[0])
218 inWhole = true
219 continue
220 }
221
222 if inWhole {
223 if count == 3 {
224 b = append(b, haw.group[0])
225 count = 1
226 } else {
227 count++
228 }
229 }
230
231 b = append(b, s[i])
232 }
233
234 if num < 0 {
235 b = append(b, haw.minus[0])
236 }
237
238
239 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240 b[i], b[j] = b[j], b[i]
241 }
242
243 return string(b)
244 }
245
246
247
248 func (haw *haw_US) FmtPercent(num float64, v uint64) string {
249 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250 l := len(s) + 3
251 b := make([]byte, 0, l)
252
253 for i := len(s) - 1; i >= 0; i-- {
254
255 if s[i] == '.' {
256 b = append(b, haw.decimal[0])
257 continue
258 }
259
260 b = append(b, s[i])
261 }
262
263 if num < 0 {
264 b = append(b, haw.minus[0])
265 }
266
267
268 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
269 b[i], b[j] = b[j], b[i]
270 }
271
272 b = append(b, haw.percent...)
273
274 return string(b)
275 }
276
277
278 func (haw *haw_US) FmtCurrency(num float64, v uint64, currency currency.Type) string {
279
280 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
281 symbol := haw.currencies[currency]
282 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
283 count := 0
284 inWhole := v == 0
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, haw.decimal[0])
291 inWhole = true
292 continue
293 }
294
295 if inWhole {
296 if count == 3 {
297 b = append(b, haw.group[0])
298 count = 1
299 } else {
300 count++
301 }
302 }
303
304 b = append(b, s[i])
305 }
306
307 for j := len(symbol) - 1; j >= 0; j-- {
308 b = append(b, symbol[j])
309 }
310
311 if num < 0 {
312 b = append(b, haw.minus[0])
313 }
314
315
316 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
317 b[i], b[j] = b[j], b[i]
318 }
319
320 if int(v) < 2 {
321
322 if v == 0 {
323 b = append(b, haw.decimal...)
324 }
325
326 for i := 0; i < 2-int(v); i++ {
327 b = append(b, '0')
328 }
329 }
330
331 return string(b)
332 }
333
334
335
336 func (haw *haw_US) FmtAccounting(num float64, v uint64, currency currency.Type) string {
337
338 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339 symbol := haw.currencies[currency]
340 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
341 count := 0
342 inWhole := v == 0
343 b := make([]byte, 0, l)
344
345 for i := len(s) - 1; i >= 0; i-- {
346
347 if s[i] == '.' {
348 b = append(b, haw.decimal[0])
349 inWhole = true
350 continue
351 }
352
353 if inWhole {
354 if count == 3 {
355 b = append(b, haw.group[0])
356 count = 1
357 } else {
358 count++
359 }
360 }
361
362 b = append(b, s[i])
363 }
364
365 if num < 0 {
366
367 for j := len(symbol) - 1; j >= 0; j-- {
368 b = append(b, symbol[j])
369 }
370
371 b = append(b, haw.currencyNegativePrefix[0])
372
373 } else {
374
375 for j := len(symbol) - 1; j >= 0; j-- {
376 b = append(b, symbol[j])
377 }
378
379 }
380
381
382 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
383 b[i], b[j] = b[j], b[i]
384 }
385
386 if int(v) < 2 {
387
388 if v == 0 {
389 b = append(b, haw.decimal...)
390 }
391
392 for i := 0; i < 2-int(v); i++ {
393 b = append(b, '0')
394 }
395 }
396
397 if num < 0 {
398 b = append(b, haw.currencyNegativeSuffix...)
399 }
400
401 return string(b)
402 }
403
404
405 func (haw *haw_US) FmtDateShort(t time.Time) string {
406
407 b := make([]byte, 0, 32)
408
409 b = strconv.AppendInt(b, int64(t.Day()), 10)
410 b = append(b, []byte{0x2f}...)
411 b = strconv.AppendInt(b, int64(t.Month()), 10)
412 b = append(b, []byte{0x2f}...)
413
414 if t.Year() > 9 {
415 b = append(b, strconv.Itoa(t.Year())[2:]...)
416 } else {
417 b = append(b, strconv.Itoa(t.Year())[1:]...)
418 }
419
420 return string(b)
421 }
422
423
424 func (haw *haw_US) FmtDateMedium(t time.Time) string {
425
426 b := make([]byte, 0, 32)
427
428 b = strconv.AppendInt(b, int64(t.Day()), 10)
429 b = append(b, []byte{0x20}...)
430 b = append(b, haw.monthsAbbreviated[t.Month()]...)
431 b = append(b, []byte{0x20}...)
432
433 if t.Year() > 0 {
434 b = strconv.AppendInt(b, int64(t.Year()), 10)
435 } else {
436 b = strconv.AppendInt(b, int64(-t.Year()), 10)
437 }
438
439 return string(b)
440 }
441
442
443 func (haw *haw_US) FmtDateLong(t time.Time) string {
444
445 b := make([]byte, 0, 32)
446
447 b = strconv.AppendInt(b, int64(t.Day()), 10)
448 b = append(b, []byte{0x20}...)
449 b = append(b, haw.monthsWide[t.Month()]...)
450 b = append(b, []byte{0x20}...)
451
452 if t.Year() > 0 {
453 b = strconv.AppendInt(b, int64(t.Year()), 10)
454 } else {
455 b = strconv.AppendInt(b, int64(-t.Year()), 10)
456 }
457
458 return string(b)
459 }
460
461
462 func (haw *haw_US) FmtDateFull(t time.Time) string {
463
464 b := make([]byte, 0, 32)
465
466 b = append(b, haw.daysWide[t.Weekday()]...)
467 b = append(b, []byte{0x2c, 0x20}...)
468 b = strconv.AppendInt(b, int64(t.Day()), 10)
469 b = append(b, []byte{0x20}...)
470 b = append(b, haw.monthsWide[t.Month()]...)
471 b = append(b, []byte{0x20}...)
472
473 if t.Year() > 0 {
474 b = strconv.AppendInt(b, int64(t.Year()), 10)
475 } else {
476 b = strconv.AppendInt(b, int64(-t.Year()), 10)
477 }
478
479 return string(b)
480 }
481
482
483 func (haw *haw_US) FmtTimeShort(t time.Time) string {
484
485 b := make([]byte, 0, 32)
486
487 h := t.Hour()
488
489 if h > 12 {
490 h -= 12
491 }
492
493 b = strconv.AppendInt(b, int64(h), 10)
494 b = append(b, haw.timeSeparator...)
495
496 if t.Minute() < 10 {
497 b = append(b, '0')
498 }
499
500 b = strconv.AppendInt(b, int64(t.Minute()), 10)
501 b = append(b, []byte{0x20}...)
502
503 if t.Hour() < 12 {
504 b = append(b, haw.periodsAbbreviated[0]...)
505 } else {
506 b = append(b, haw.periodsAbbreviated[1]...)
507 }
508
509 return string(b)
510 }
511
512
513 func (haw *haw_US) FmtTimeMedium(t time.Time) string {
514
515 b := make([]byte, 0, 32)
516
517 h := t.Hour()
518
519 if h > 12 {
520 h -= 12
521 }
522
523 b = strconv.AppendInt(b, int64(h), 10)
524 b = append(b, haw.timeSeparator...)
525
526 if t.Minute() < 10 {
527 b = append(b, '0')
528 }
529
530 b = strconv.AppendInt(b, int64(t.Minute()), 10)
531 b = append(b, haw.timeSeparator...)
532
533 if t.Second() < 10 {
534 b = append(b, '0')
535 }
536
537 b = strconv.AppendInt(b, int64(t.Second()), 10)
538 b = append(b, []byte{0x20}...)
539
540 if t.Hour() < 12 {
541 b = append(b, haw.periodsAbbreviated[0]...)
542 } else {
543 b = append(b, haw.periodsAbbreviated[1]...)
544 }
545
546 return string(b)
547 }
548
549
550 func (haw *haw_US) FmtTimeLong(t time.Time) string {
551
552 b := make([]byte, 0, 32)
553
554 h := t.Hour()
555
556 if h > 12 {
557 h -= 12
558 }
559
560 b = strconv.AppendInt(b, int64(h), 10)
561 b = append(b, haw.timeSeparator...)
562
563 if t.Minute() < 10 {
564 b = append(b, '0')
565 }
566
567 b = strconv.AppendInt(b, int64(t.Minute()), 10)
568 b = append(b, haw.timeSeparator...)
569
570 if t.Second() < 10 {
571 b = append(b, '0')
572 }
573
574 b = strconv.AppendInt(b, int64(t.Second()), 10)
575 b = append(b, []byte{0x20}...)
576
577 if t.Hour() < 12 {
578 b = append(b, haw.periodsAbbreviated[0]...)
579 } else {
580 b = append(b, haw.periodsAbbreviated[1]...)
581 }
582
583 b = append(b, []byte{0x20}...)
584
585 tz, _ := t.Zone()
586 b = append(b, tz...)
587
588 return string(b)
589 }
590
591
592 func (haw *haw_US) FmtTimeFull(t time.Time) string {
593
594 b := make([]byte, 0, 32)
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, haw.timeSeparator...)
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, haw.timeSeparator...)
611
612 if t.Second() < 10 {
613 b = append(b, '0')
614 }
615
616 b = strconv.AppendInt(b, int64(t.Second()), 10)
617 b = append(b, []byte{0x20}...)
618
619 if t.Hour() < 12 {
620 b = append(b, haw.periodsAbbreviated[0]...)
621 } else {
622 b = append(b, haw.periodsAbbreviated[1]...)
623 }
624
625 b = append(b, []byte{0x20}...)
626
627 tz, _ := t.Zone()
628
629 if btz, ok := haw.timezones[tz]; ok {
630 b = append(b, btz...)
631 } else {
632 b = append(b, tz...)
633 }
634
635 return string(b)
636 }
637
View as plain text