1 package dyo_SN
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 dyo_SN 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 currencyPositiveSuffix 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 &dyo_SN{
47 locale: "dyo_SN",
48 pluralsCardinal: nil,
49 pluralsOrdinal: nil,
50 pluralsRange: nil,
51 decimal: ",",
52 group: " ",
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 currencyPositiveSuffix: " ",
56 currencyNegativeSuffix: " ",
57 monthsAbbreviated: []string{"", "Sa", "Fe", "Ma", "Ab", "Me", "Su", "Sú", "Ut", "Se", "Ok", "No", "De"},
58 monthsNarrow: []string{"", "S", "F", "M", "A", "M", "S", "S", "U", "S", "O", "N", "D"},
59 monthsWide: []string{"", "Sanvie", "Fébirie", "Mars", "Aburil", "Mee", "Sueŋ", "Súuyee", "Ut", "Settembar", "Oktobar", "Novembar", "Disambar"},
60 daysAbbreviated: []string{"Dim", "Ten", "Tal", "Ala", "Ara", "Arj", "Sib"},
61 daysNarrow: []string{"D", "T", "T", "A", "A", "A", "S"},
62 daysWide: []string{"Dimas", "Teneŋ", "Talata", "Alarbay", "Aramisay", "Arjuma", "Sibiti"},
63 erasAbbreviated: []string{"ArY", "AtY"},
64 erasNarrow: []string{"", ""},
65 erasWide: []string{"Ariŋuu Yeesu", "Atooŋe Yeesu"},
66 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", "∅∅∅": "∅∅∅"},
67 }
68 }
69
70
71 func (dyo *dyo_SN) Locale() string {
72 return dyo.locale
73 }
74
75
76 func (dyo *dyo_SN) PluralsCardinal() []locales.PluralRule {
77 return dyo.pluralsCardinal
78 }
79
80
81 func (dyo *dyo_SN) PluralsOrdinal() []locales.PluralRule {
82 return dyo.pluralsOrdinal
83 }
84
85
86 func (dyo *dyo_SN) PluralsRange() []locales.PluralRule {
87 return dyo.pluralsRange
88 }
89
90
91 func (dyo *dyo_SN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
92 return locales.PluralRuleUnknown
93 }
94
95
96 func (dyo *dyo_SN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
97 return locales.PluralRuleUnknown
98 }
99
100
101 func (dyo *dyo_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
102 return locales.PluralRuleUnknown
103 }
104
105
106 func (dyo *dyo_SN) MonthAbbreviated(month time.Month) string {
107 return dyo.monthsAbbreviated[month]
108 }
109
110
111 func (dyo *dyo_SN) MonthsAbbreviated() []string {
112 return dyo.monthsAbbreviated[1:]
113 }
114
115
116 func (dyo *dyo_SN) MonthNarrow(month time.Month) string {
117 return dyo.monthsNarrow[month]
118 }
119
120
121 func (dyo *dyo_SN) MonthsNarrow() []string {
122 return dyo.monthsNarrow[1:]
123 }
124
125
126 func (dyo *dyo_SN) MonthWide(month time.Month) string {
127 return dyo.monthsWide[month]
128 }
129
130
131 func (dyo *dyo_SN) MonthsWide() []string {
132 return dyo.monthsWide[1:]
133 }
134
135
136 func (dyo *dyo_SN) WeekdayAbbreviated(weekday time.Weekday) string {
137 return dyo.daysAbbreviated[weekday]
138 }
139
140
141 func (dyo *dyo_SN) WeekdaysAbbreviated() []string {
142 return dyo.daysAbbreviated
143 }
144
145
146 func (dyo *dyo_SN) WeekdayNarrow(weekday time.Weekday) string {
147 return dyo.daysNarrow[weekday]
148 }
149
150
151 func (dyo *dyo_SN) WeekdaysNarrow() []string {
152 return dyo.daysNarrow
153 }
154
155
156 func (dyo *dyo_SN) WeekdayShort(weekday time.Weekday) string {
157 return dyo.daysShort[weekday]
158 }
159
160
161 func (dyo *dyo_SN) WeekdaysShort() []string {
162 return dyo.daysShort
163 }
164
165
166 func (dyo *dyo_SN) WeekdayWide(weekday time.Weekday) string {
167 return dyo.daysWide[weekday]
168 }
169
170
171 func (dyo *dyo_SN) WeekdaysWide() []string {
172 return dyo.daysWide
173 }
174
175
176 func (dyo *dyo_SN) Decimal() string {
177 return dyo.decimal
178 }
179
180
181 func (dyo *dyo_SN) Group() string {
182 return dyo.group
183 }
184
185
186 func (dyo *dyo_SN) Minus() string {
187 return dyo.minus
188 }
189
190
191 func (dyo *dyo_SN) FmtNumber(num float64, v uint64) string {
192
193 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
194 l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
195 count := 0
196 inWhole := v == 0
197 b := make([]byte, 0, l)
198
199 for i := len(s) - 1; i >= 0; i-- {
200
201 if s[i] == '.' {
202 b = append(b, dyo.decimal[0])
203 inWhole = true
204 continue
205 }
206
207 if inWhole {
208 if count == 3 {
209 for j := len(dyo.group) - 1; j >= 0; j-- {
210 b = append(b, dyo.group[j])
211 }
212 count = 1
213 } else {
214 count++
215 }
216 }
217
218 b = append(b, s[i])
219 }
220
221 if num < 0 {
222 b = append(b, dyo.minus[0])
223 }
224
225
226 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
227 b[i], b[j] = b[j], b[i]
228 }
229
230 return string(b)
231 }
232
233
234
235 func (dyo *dyo_SN) FmtPercent(num float64, v uint64) string {
236 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
237 l := len(s) + 1
238 b := make([]byte, 0, l)
239
240 for i := len(s) - 1; i >= 0; i-- {
241
242 if s[i] == '.' {
243 b = append(b, dyo.decimal[0])
244 continue
245 }
246
247 b = append(b, s[i])
248 }
249
250 if num < 0 {
251 b = append(b, dyo.minus[0])
252 }
253
254
255 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
256 b[i], b[j] = b[j], b[i]
257 }
258
259 b = append(b, dyo.percent...)
260
261 return string(b)
262 }
263
264
265 func (dyo *dyo_SN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
266
267 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
268 symbol := dyo.currencies[currency]
269 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
270 count := 0
271 inWhole := v == 0
272 b := make([]byte, 0, l)
273
274 for i := len(s) - 1; i >= 0; i-- {
275
276 if s[i] == '.' {
277 b = append(b, dyo.decimal[0])
278 inWhole = true
279 continue
280 }
281
282 if inWhole {
283 if count == 3 {
284 for j := len(dyo.group) - 1; j >= 0; j-- {
285 b = append(b, dyo.group[j])
286 }
287 count = 1
288 } else {
289 count++
290 }
291 }
292
293 b = append(b, s[i])
294 }
295
296 if num < 0 {
297 b = append(b, dyo.minus[0])
298 }
299
300
301 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
302 b[i], b[j] = b[j], b[i]
303 }
304
305 if int(v) < 2 {
306
307 if v == 0 {
308 b = append(b, dyo.decimal...)
309 }
310
311 for i := 0; i < 2-int(v); i++ {
312 b = append(b, '0')
313 }
314 }
315
316 b = append(b, dyo.currencyPositiveSuffix...)
317
318 b = append(b, symbol...)
319
320 return string(b)
321 }
322
323
324
325 func (dyo *dyo_SN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
326
327 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
328 symbol := dyo.currencies[currency]
329 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
330 count := 0
331 inWhole := v == 0
332 b := make([]byte, 0, l)
333
334 for i := len(s) - 1; i >= 0; i-- {
335
336 if s[i] == '.' {
337 b = append(b, dyo.decimal[0])
338 inWhole = true
339 continue
340 }
341
342 if inWhole {
343 if count == 3 {
344 for j := len(dyo.group) - 1; j >= 0; j-- {
345 b = append(b, dyo.group[j])
346 }
347 count = 1
348 } else {
349 count++
350 }
351 }
352
353 b = append(b, s[i])
354 }
355
356 if num < 0 {
357
358 b = append(b, dyo.minus[0])
359
360 }
361
362
363 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
364 b[i], b[j] = b[j], b[i]
365 }
366
367 if int(v) < 2 {
368
369 if v == 0 {
370 b = append(b, dyo.decimal...)
371 }
372
373 for i := 0; i < 2-int(v); i++ {
374 b = append(b, '0')
375 }
376 }
377
378 if num < 0 {
379 b = append(b, dyo.currencyNegativeSuffix...)
380 b = append(b, symbol...)
381 } else {
382
383 b = append(b, dyo.currencyPositiveSuffix...)
384 b = append(b, symbol...)
385 }
386
387 return string(b)
388 }
389
390
391 func (dyo *dyo_SN) FmtDateShort(t time.Time) string {
392
393 b := make([]byte, 0, 32)
394
395 b = strconv.AppendInt(b, int64(t.Day()), 10)
396 b = append(b, []byte{0x2f}...)
397 b = strconv.AppendInt(b, int64(t.Month()), 10)
398 b = append(b, []byte{0x2f}...)
399
400 if t.Year() > 0 {
401 b = strconv.AppendInt(b, int64(t.Year()), 10)
402 } else {
403 b = strconv.AppendInt(b, int64(-t.Year()), 10)
404 }
405
406 return string(b)
407 }
408
409
410 func (dyo *dyo_SN) FmtDateMedium(t time.Time) string {
411
412 b := make([]byte, 0, 32)
413
414 b = strconv.AppendInt(b, int64(t.Day()), 10)
415 b = append(b, []byte{0x20}...)
416 b = append(b, dyo.monthsAbbreviated[t.Month()]...)
417 b = append(b, []byte{0x20}...)
418
419 if t.Year() > 0 {
420 b = strconv.AppendInt(b, int64(t.Year()), 10)
421 } else {
422 b = strconv.AppendInt(b, int64(-t.Year()), 10)
423 }
424
425 return string(b)
426 }
427
428
429 func (dyo *dyo_SN) FmtDateLong(t time.Time) string {
430
431 b := make([]byte, 0, 32)
432
433 b = strconv.AppendInt(b, int64(t.Day()), 10)
434 b = append(b, []byte{0x20}...)
435 b = append(b, dyo.monthsWide[t.Month()]...)
436 b = append(b, []byte{0x20}...)
437
438 if t.Year() > 0 {
439 b = strconv.AppendInt(b, int64(t.Year()), 10)
440 } else {
441 b = strconv.AppendInt(b, int64(-t.Year()), 10)
442 }
443
444 return string(b)
445 }
446
447
448 func (dyo *dyo_SN) FmtDateFull(t time.Time) string {
449
450 b := make([]byte, 0, 32)
451
452 b = append(b, dyo.daysWide[t.Weekday()]...)
453 b = append(b, []byte{0x20}...)
454 b = strconv.AppendInt(b, int64(t.Day()), 10)
455 b = append(b, []byte{0x20}...)
456 b = append(b, dyo.monthsWide[t.Month()]...)
457 b = append(b, []byte{0x20}...)
458
459 if t.Year() > 0 {
460 b = strconv.AppendInt(b, int64(t.Year()), 10)
461 } else {
462 b = strconv.AppendInt(b, int64(-t.Year()), 10)
463 }
464
465 return string(b)
466 }
467
468
469 func (dyo *dyo_SN) FmtTimeShort(t time.Time) string {
470
471 b := make([]byte, 0, 32)
472
473 if t.Hour() < 10 {
474 b = append(b, '0')
475 }
476
477 b = strconv.AppendInt(b, int64(t.Hour()), 10)
478 b = append(b, dyo.timeSeparator...)
479
480 if t.Minute() < 10 {
481 b = append(b, '0')
482 }
483
484 b = strconv.AppendInt(b, int64(t.Minute()), 10)
485
486 return string(b)
487 }
488
489
490 func (dyo *dyo_SN) FmtTimeMedium(t time.Time) string {
491
492 b := make([]byte, 0, 32)
493
494 if t.Hour() < 10 {
495 b = append(b, '0')
496 }
497
498 b = strconv.AppendInt(b, int64(t.Hour()), 10)
499 b = append(b, dyo.timeSeparator...)
500
501 if t.Minute() < 10 {
502 b = append(b, '0')
503 }
504
505 b = strconv.AppendInt(b, int64(t.Minute()), 10)
506 b = append(b, dyo.timeSeparator...)
507
508 if t.Second() < 10 {
509 b = append(b, '0')
510 }
511
512 b = strconv.AppendInt(b, int64(t.Second()), 10)
513
514 return string(b)
515 }
516
517
518 func (dyo *dyo_SN) FmtTimeLong(t time.Time) string {
519
520 b := make([]byte, 0, 32)
521
522 if t.Hour() < 10 {
523 b = append(b, '0')
524 }
525
526 b = strconv.AppendInt(b, int64(t.Hour()), 10)
527 b = append(b, dyo.timeSeparator...)
528
529 if t.Minute() < 10 {
530 b = append(b, '0')
531 }
532
533 b = strconv.AppendInt(b, int64(t.Minute()), 10)
534 b = append(b, dyo.timeSeparator...)
535
536 if t.Second() < 10 {
537 b = append(b, '0')
538 }
539
540 b = strconv.AppendInt(b, int64(t.Second()), 10)
541 b = append(b, []byte{0x20}...)
542
543 tz, _ := t.Zone()
544 b = append(b, tz...)
545
546 return string(b)
547 }
548
549
550 func (dyo *dyo_SN) FmtTimeFull(t time.Time) string {
551
552 b := make([]byte, 0, 32)
553
554 if t.Hour() < 10 {
555 b = append(b, '0')
556 }
557
558 b = strconv.AppendInt(b, int64(t.Hour()), 10)
559 b = append(b, dyo.timeSeparator...)
560
561 if t.Minute() < 10 {
562 b = append(b, '0')
563 }
564
565 b = strconv.AppendInt(b, int64(t.Minute()), 10)
566 b = append(b, dyo.timeSeparator...)
567
568 if t.Second() < 10 {
569 b = append(b, '0')
570 }
571
572 b = strconv.AppendInt(b, int64(t.Second()), 10)
573 b = append(b, []byte{0x20}...)
574
575 tz, _ := t.Zone()
576
577 if btz, ok := dyo.timezones[tz]; ok {
578 b = append(b, btz...)
579 } else {
580 b = append(b, tz...)
581 }
582
583 return string(b)
584 }
585
View as plain text