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