1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
package ak_GH
import (
"math"
"strconv"
"time"
"github.com/go-playground/locales"
"github.com/go-playground/locales/currency"
)
type ak_GH struct {
locale string
pluralsCardinal []locales.PluralRule
pluralsOrdinal []locales.PluralRule
decimal []byte
group []byte
minus []byte
percent []byte
percentPrefix []byte
percentSuffix []byte
perMille []byte
timeSeparator []byte
inifinity []byte
currencies [][]byte // idx = enum of currency code
currencyPositivePrefix []byte
currencyPositiveSuffix []byte
currencyNegativePrefix []byte
currencyNegativeSuffix []byte
monthsAbbreviated [][]byte
monthsNarrow [][]byte
monthsShort [][]byte
monthsWide [][]byte
daysAbbreviated [][]byte
daysNarrow [][]byte
daysShort [][]byte
daysWide [][]byte
periodsAbbreviated [][]byte
periodsNarrow [][]byte
periodsShort [][]byte
periodsWide [][]byte
erasAbbreviated [][]byte
erasNarrow [][]byte
erasWide [][]byte
}
// New returns a new instance of translator for the 'ak_GH' locale
func New() locales.Translator {
return &ak_GH{
locale: "ak_GH",
pluralsCardinal: []locales.PluralRule{2, 6},
pluralsOrdinal: nil,
decimal: []byte{0x2e},
group: []byte{0x2c},
minus: []byte{},
percent: []byte{},
perMille: []byte{},
timeSeparator: []byte{0x3a},
currencies: [][]uint8{{0x41, 0x44, 0x50}, {0x41, 0x45, 0x44}, {0x41, 0x46, 0x41}, {0x41, 0x46, 0x4e}, {0x41, 0x4c, 0x4b}, {0x41, 0x4c, 0x4c}, {0x41, 0x4d, 0x44}, {0x41, 0x4e, 0x47}, {0x41, 0x4f, 0x41}, {0x41, 0x4f, 0x4b}, {0x41, 0x4f, 0x4e}, {0x41, 0x4f, 0x52}, {0x41, 0x52, 0x41}, {0x41, 0x52, 0x4c}, {0x41, 0x52, 0x4d}, {0x41, 0x52, 0x50}, {0x41, 0x52, 0x53}, {0x41, 0x54, 0x53}, {0x41, 0x55, 0x44}, {0x41, 0x57, 0x47}, {0x41, 0x5a, 0x4d}, {0x41, 0x5a, 0x4e}, {0x42, 0x41, 0x44}, {0x42, 0x41, 0x4d}, {0x42, 0x41, 0x4e}, {0x42, 0x42, 0x44}, {0x42, 0x44, 0x54}, {0x42, 0x45, 0x43}, {0x42, 0x45, 0x46}, {0x42, 0x45, 0x4c}, {0x42, 0x47, 0x4c}, {0x42, 0x47, 0x4d}, {0x42, 0x47, 0x4e}, {0x42, 0x47, 0x4f}, {0x42, 0x48, 0x44}, {0x42, 0x49, 0x46}, {0x42, 0x4d, 0x44}, {0x42, 0x4e, 0x44}, {0x42, 0x4f, 0x42}, {0x42, 0x4f, 0x4c}, {0x42, 0x4f, 0x50}, {0x42, 0x4f, 0x56}, {0x42, 0x52, 0x42}, {0x42, 0x52, 0x43}, {0x42, 0x52, 0x45}, {0x42, 0x52, 0x4c}, {0x42, 0x52, 0x4e}, {0x42, 0x52, 0x52}, {0x42, 0x52, 0x5a}, {0x42, 0x53, 0x44}, {0x42, 0x54, 0x4e}, {0x42, 0x55, 0x4b}, {0x42, 0x57, 0x50}, {0x42, 0x59, 0x42}, {0x42, 0x59, 0x52}, {0x42, 0x5a, 0x44}, {0x43, 0x41, 0x44}, {0x43, 0x44, 0x46}, {0x43, 0x48, 0x45}, {0x43, 0x48, 0x46}, {0x43, 0x48, 0x57}, {0x43, 0x4c, 0x45}, {0x43, 0x4c, 0x46}, {0x43, 0x4c, 0x50}, {0x43, 0x4e, 0x58}, {0x43, 0x4e, 0x59}, {0x43, 0x4f, 0x50}, {0x43, 0x4f, 0x55}, {0x43, 0x52, 0x43}, {0x43, 0x53, 0x44}, {0x43, 0x53, 0x4b}, {0x43, 0x55, 0x43}, {0x43, 0x55, 0x50}, {0x43, 0x56, 0x45}, {0x43, 0x59, 0x50}, {0x43, 0x5a, 0x4b}, {0x44, 0x44, 0x4d}, {0x44, 0x45, 0x4d}, {0x44, 0x4a, 0x46}, {0x44, 0x4b, 0x4b}, {0x44, 0x4f, 0x50}, {0x44, 0x5a, 0x44}, {0x45, 0x43, 0x53}, {0x45, 0x43, 0x56}, {0x45, 0x45, 0x4b}, {0x45, 0x47, 0x50}, {0x45, 0x52, 0x4e}, {0x45, 0x53, 0x41}, {0x45, 0x53, 0x42}, {0x45, 0x53, 0x50}, {0x45, 0x54, 0x42}, {0x45, 0x55, 0x52}, {0x46, 0x49, 0x4d}, {0x46, 0x4a, 0x44}, {0x46, 0x4b, 0x50}, {0x46, 0x52, 0x46}, {0x47, 0x42, 0x50}, {0x47, 0x45, 0x4b}, {0x47, 0x45, 0x4c}, {0x47, 0x48, 0x43}, {0x47, 0x48, 0x53}, {0x47, 0x49, 0x50}, {0x47, 0x4d, 0x44}, {0x47, 0x4e, 0x46}, {0x47, 0x4e, 0x53}, {0x47, 0x51, 0x45}, {0x47, 0x52, 0x44}, {0x47, 0x54, 0x51}, {0x47, 0x57, 0x45}, {0x47, 0x57, 0x50}, {0x47, 0x59, 0x44}, {0x48, 0x4b, 0x44}, {0x48, 0x4e, 0x4c}, {0x48, 0x52, 0x44}, {0x48, 0x52, 0x4b}, {0x48, 0x54, 0x47}, {0x48, 0x55, 0x46}, {0x49, 0x44, 0x52}, {0x49, 0x45, 0x50}, {0x49, 0x4c, 0x50}, {0x49, 0x4c, 0x52}, {0x49, 0x4c, 0x53}, {0x49, 0x4e, 0x52}, {0x49, 0x51, 0x44}, {0x49, 0x52, 0x52}, {0x49, 0x53, 0x4a}, {0x49, 0x53, 0x4b}, {0x49, 0x54, 0x4c}, {0x4a, 0x4d, 0x44}, {0x4a, 0x4f, 0x44}, {0x4a, 0x50, 0x59}, {0x4b, 0x45, 0x53}, {0x4b, 0x47, 0x53}, {0x4b, 0x48, 0x52}, {0x4b, 0x4d, 0x46}, {0x4b, 0x50, 0x57}, {0x4b, 0x52, 0x48}, {0x4b, 0x52, 0x4f}, {0x4b, 0x52, 0x57}, {0x4b, 0x57, 0x44}, {0x4b, 0x59, 0x44}, {0x4b, 0x5a, 0x54}, {0x4c, 0x41, 0x4b}, {0x4c, 0x42, 0x50}, {0x4c, 0x4b, 0x52}, {0x4c, 0x52, 0x44}, {0x4c, 0x53, 0x4c}, {0x4c, 0x54, 0x4c}, {0x4c, 0x54, 0x54}, {0x4c, 0x55, 0x43}, {0x4c, 0x55, 0x46}, {0x4c, 0x55, 0x4c}, {0x4c, 0x56, 0x4c}, {0x4c, 0x56, 0x52}, {0x4c, 0x59, 0x44}, {0x4d, 0x41, 0x44}, {0x4d, 0x41, 0x46}, {0x4d, 0x43, 0x46}, {0x4d, 0x44, 0x43}, {0x4d, 0x44, 0x4c}, {0x4d, 0x47, 0x41}, {0x4d, 0x47, 0x46}, {0x4d, 0x4b, 0x44}, {0x4d, 0x4b, 0x4e}, {0x4d, 0x4c, 0x46}, {0x4d, 0x4d, 0x4b}, {0x4d, 0x4e, 0x54}, {0x4d, 0x4f, 0x50}, {0x4d, 0x52, 0x4f}, {0x4d, 0x54, 0x4c}, {0x4d, 0x54, 0x50}, {0x4d, 0x55, 0x52}, {0x4d, 0x56, 0x50}, {0x4d, 0x56, 0x52}, {0x4d, 0x57, 0x4b}, {0x4d, 0x58, 0x4e}, {0x4d, 0x58, 0x50}, {0x4d, 0x58, 0x56}, {0x4d, 0x59, 0x52}, {0x4d, 0x5a, 0x45}, {0x4d, 0x5a, 0x4d}, {0x4d, 0x5a, 0x4e}, {0x4e, 0x41, 0x44}, {0x4e, 0x47, 0x4e}, {0x4e, 0x49, 0x43}, {0x4e, 0x49, 0x4f}, {0x4e, 0x4c, 0x47}, {0x4e, 0x4f, 0x4b}, {0x4e, 0x50, 0x52}, {0x4e, 0x5a, 0x44}, {0x4f, 0x4d, 0x52}, {0x50, 0x41, 0x42}, {0x50, 0x45, 0x49}, {0x50, 0x45, 0x4e}, {0x50, 0x45, 0x53}, {0x50, 0x47, 0x4b}, {0x50, 0x48, 0x50}, {0x50, 0x4b, 0x52}, {0x50, 0x4c, 0x4e}, {0x50, 0x4c, 0x5a}, {0x50, 0x54, 0x45}, {0x50, 0x59, 0x47}, {0x51, 0x41, 0x52}, {0x52, 0x48, 0x44}, {0x52, 0x4f, 0x4c}, {0x52, 0x4f, 0x4e}, {0x52, 0x53, 0x44}, {0x52, 0x55, 0x42}, {0x52, 0x55, 0x52}, {0x52, 0x57, 0x46}, {0x53, 0x41, 0x52}, {0x53, 0x42, 0x44}, {0x53, 0x43, 0x52}, {0x53, 0x44, 0x44}, {0x53, 0x44, 0x47}, {0x53, 0x44, 0x50}, {0x53, 0x45, 0x4b}, {0x53, 0x47, 0x44}, {0x53, 0x48, 0x50}, {0x53, 0x49, 0x54}, {0x53, 0x4b, 0x4b}, {0x53, 0x4c, 0x4c}, {0x53, 0x4f, 0x53}, {0x53, 0x52, 0x44}, {0x53, 0x52, 0x47}, {0x53, 0x53, 0x50}, {0x53, 0x54, 0x44}, {0x53, 0x55, 0x52}, {0x53, 0x56, 0x43}, {0x53, 0x59, 0x50}, {0x53, 0x5a, 0x4c}, {0x54, 0x48, 0x42}, {0x54, 0x4a, 0x52}, {0x54, 0x4a, 0x53}, {0x54, 0x4d, 0x4d}, {0x54, 0x4d, 0x54}, {0x54, 0x4e, 0x44}, {0x54, 0x4f, 0x50}, {0x54, 0x50, 0x45}, {0x54, 0x52, 0x4c}, {0x54, 0x52, 0x59}, {0x54, 0x54, 0x44}, {0x54, 0x57, 0x44}, {0x54, 0x5a, 0x53}, {0x55, 0x41, 0x48}, {0x55, 0x41, 0x4b}, {0x55, 0x47, 0x53}, {0x55, 0x47, 0x58}, {0x55, 0x53, 0x44}, {0x55, 0x53, 0x4e}, {0x55, 0x53, 0x53}, {0x55, 0x59, 0x49}, {0x55, 0x59, 0x50}, {0x55, 0x59, 0x55}, {0x55, 0x5a, 0x53}, {0x56, 0x45, 0x42}, {0x56, 0x45, 0x46}, {0x56, 0x4e, 0x44}, {0x56, 0x4e, 0x4e}, {0x56, 0x55, 0x56}, {0x57, 0x53, 0x54}, {0x58, 0x41, 0x46}, {0x58, 0x41, 0x47}, {0x58, 0x41, 0x55}, {0x58, 0x42, 0x41}, {0x58, 0x42, 0x42}, {0x58, 0x42, 0x43}, {0x58, 0x42, 0x44}, {0x58, 0x43, 0x44}, {0x58, 0x44, 0x52}, {0x58, 0x45, 0x55}, {0x58, 0x46, 0x4f}, {0x58, 0x46, 0x55}, {0x58, 0x4f, 0x46}, {0x58, 0x50, 0x44}, {0x58, 0x50, 0x46}, {0x58, 0x50, 0x54}, {0x58, 0x52, 0x45}, {0x58, 0x53, 0x55}, {0x58, 0x54, 0x53}, {0x58, 0x55, 0x41}, {0x58, 0x58, 0x58}, {0x59, 0x44, 0x44}, {0x59, 0x45, 0x52}, {0x59, 0x55, 0x44}, {0x59, 0x55, 0x4d}, {0x59, 0x55, 0x4e}, {0x59, 0x55, 0x52}, {0x5a, 0x41, 0x4c}, {0x5a, 0x41, 0x52}, {0x5a, 0x4d, 0x4b}, {0x5a, 0x4d, 0x57}, {0x5a, 0x52, 0x4e}, {0x5a, 0x52, 0x5a}, {0x5a, 0x57, 0x44}, {0x5a, 0x57, 0x4c}, {0x5a, 0x57, 0x52}},
monthsAbbreviated: [][]uint8{[]uint8(nil), {0x53, 0x2d, 0xc6, 0x86}, {0x4b, 0x2d, 0xc6, 0x86}, {0x45, 0x2d, 0xc6, 0x86}, {0x45, 0x2d, 0x4f}, {0x45, 0x2d, 0x4b}, {0x4f, 0x2d, 0x41}, {0x41, 0x2d, 0x4b}, {0x44, 0x2d, 0xc6, 0x86}, {0x46, 0x2d, 0xc6, 0x90}, {0xc6, 0x86, 0x2d, 0x41}, {0xc6, 0x86, 0x2d, 0x4f}, {0x4d, 0x2d, 0xc6, 0x86}},
monthsWide: [][]uint8{[]uint8(nil), {0x53, 0x61, 0x6e, 0x64, 0x61, 0x2d, 0xc6, 0x86, 0x70, 0xc9, 0x9b, 0x70, 0xc9, 0x94, 0x6e}, {0x4b, 0x77, 0x61, 0x6b, 0x77, 0x61, 0x72, 0x2d, 0xc6, 0x86, 0x67, 0x79, 0x65, 0x66, 0x75, 0x6f}, {0x45, 0x62, 0xc9, 0x94, 0x77, 0x2d, 0xc6, 0x86, 0x62, 0x65, 0x6e, 0x65, 0x6d}, {0x45, 0x62, 0xc9, 0x94, 0x62, 0x69, 0x72, 0x61, 0x2d, 0x4f, 0x66, 0x6f, 0x72, 0x69, 0x73, 0x75, 0x6f}, {0x45, 0x73, 0x75, 0x73, 0x6f, 0x77, 0x20, 0x41, 0x6b, 0x65, 0x74, 0x73, 0x65, 0x61, 0x62, 0x61, 0x2d, 0x4b, 0xc9, 0x94, 0x74, 0xc9, 0x94, 0x6e, 0x69, 0x6d, 0x62, 0x61}, {0x4f, 0x62, 0x69, 0x72, 0x61, 0x64, 0x65, 0x2d, 0x41, 0x79, 0xc9, 0x9b, 0x77, 0x6f, 0x68, 0x6f, 0x6d, 0x75, 0x6d, 0x75}, {0x41, 0x79, 0xc9, 0x9b, 0x77, 0x6f, 0x68, 0x6f, 0x2d, 0x4b, 0x69, 0x74, 0x61, 0x77, 0x6f, 0x6e, 0x73, 0x61}, {0x44, 0x69, 0x66, 0x75, 0x75, 0x2d, 0xc6, 0x86, 0x73, 0x61, 0x6e, 0x64, 0x61, 0x61}, {0x46, 0x61, 0x6e, 0x6b, 0x77, 0x61, 0x2d, 0xc6, 0x90, 0x62, 0xc9, 0x94}, {0xc6, 0x86, 0x62, 0xc9, 0x9b, 0x73, 0xc9, 0x9b, 0x2d, 0x41, 0x68, 0x69, 0x6e, 0x69, 0x6d, 0x65}, {0xc6, 0x86, 0x62, 0x65, 0x72, 0xc9, 0x9b, 0x66, 0xc9, 0x9b, 0x77, 0x2d, 0x4f, 0x62, 0x75, 0x62, 0x75, 0x6f}, {0x4d, 0x75, 0x6d, 0x75, 0x2d, 0xc6, 0x86, 0x70, 0xc9, 0x9b, 0x6e, 0x69, 0x6d, 0x62, 0x61}},
daysAbbreviated: [][]uint8{{0x4b, 0x77, 0x65}, {0x44, 0x77, 0x6f}, {0x42, 0x65, 0x6e}, {0x57, 0x75, 0x6b}, {0x59, 0x61, 0x77}, {0x46, 0x69, 0x61}, {0x4d, 0x65, 0x6d}},
daysNarrow: [][]uint8{{0x4b}, {0x44}, {0x42}, {0x57}, {0x59}, {0x46}, {0x4d}},
daysWide: [][]uint8{{0x4b, 0x77, 0x65, 0x73, 0x69, 0x64, 0x61}, {0x44, 0x77, 0x6f, 0x77, 0x64, 0x61}, {0x42, 0x65, 0x6e, 0x61, 0x64, 0x61}, {0x57, 0x75, 0x6b, 0x75, 0x64, 0x61}, {0x59, 0x61, 0x77, 0x64, 0x61}, {0x46, 0x69, 0x64, 0x61}, {0x4d, 0x65, 0x6d, 0x65, 0x6e, 0x65, 0x64, 0x61}},
periodsAbbreviated: [][]uint8{{0x41, 0x4e}, {0x45, 0x57}},
periodsWide: [][]uint8{{0x41, 0x4e}, {0x45, 0x57}},
erasAbbreviated: [][]uint8{{0x41, 0x4b}, {0x4b, 0x45}},
erasNarrow: [][]uint8{[]uint8(nil), []uint8(nil)},
erasWide: [][]uint8{{0x41, 0x6e, 0x73, 0x61, 0x20, 0x4b, 0x72, 0x69, 0x73, 0x74, 0x6f}, {0x4b, 0x72, 0x69, 0x73, 0x74, 0x6f, 0x20, 0x45, 0x6b, 0x79, 0x69, 0x72, 0x69}},
}
}
// Locale returns the current translators string locale
func (ak *ak_GH) Locale() string {
return ak.locale
}
// PluralsCardinal returns the list of cardinal plural rules associated with 'ak_GH'
func (ak *ak_GH) PluralsCardinal() []locales.PluralRule {
return ak.pluralsCardinal
}
// PluralsOrdinal returns the list of ordinal plural rules associated with 'ak_GH'
func (ak *ak_GH) PluralsOrdinal() []locales.PluralRule {
return ak.pluralsOrdinal
}
// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ak_GH'
func (ak *ak_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
if n >= 0 && n <= 1 {
return locales.PluralRuleOne
}
return locales.PluralRuleOther
}
// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ak_GH'
func (ak *ak_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
return locales.PluralRuleUnknown
}
// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ak_GH'
func (ak *ak_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
return locales.PluralRuleUnknown
}
// FmtNumber returns 'num' with digits/precision of 'v' for 'ak_GH' and handles both Whole and Real numbers based on 'v'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtNumber(num float64, v uint64) []byte {
s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
}
// FmtPercent returns 'num' with digits/precision of 'v' for 'ak_GH' and handles both Whole and Real numbers based on 'v'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
func (ak *ak_GH) FmtPercent(num float64, v uint64) []byte {
s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
return []byte(s)
}
// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtCurrency(num float64, v uint64, currency currency.Type) []byte {
s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
symbol := ak.currencies[currency]
l := len(s) + len(ak.decimal) + len(ak.group)*len(s[:len(s)-int(v)-1])/3
count := 0
inWhole := v == 0
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
b = append(b, ak.decimal[0])
inWhole = true
continue
}
if inWhole {
if count == 3 {
b = append(b, ak.group[0])
count = 1
} else {
count++
}
}
b = append(b, s[i])
}
for j := len(symbol) - 1; j >= 0; j-- {
b = append(b, symbol[j])
}
if num < 0 {
for j := len(ak.minus) - 1; j >= 0; j-- {
b = append(b, ak.minus[j])
}
}
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
if int(v) < 2 {
if v == 0 {
b = append(b, ak.decimal...)
}
for i := 0; i < 2-int(v); i++ {
b = append(b, '0')
}
}
return b
}
// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ak_GH'
// in accounting notation. returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtAccounting(num float64, v uint64, currency currency.Type) []byte {
s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
symbol := ak.currencies[currency]
l := len(s) + len(ak.decimal) + len(ak.group)*len(s[:len(s)-int(v)-1])/3
count := 0
inWhole := v == 0
b := make([]byte, 0, l)
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
b = append(b, ak.decimal[0])
inWhole = true
continue
}
if inWhole {
if count == 3 {
b = append(b, ak.group[0])
count = 1
} else {
count++
}
}
b = append(b, s[i])
}
if num < 0 {
for j := len(symbol) - 1; j >= 0; j-- {
b = append(b, symbol[j])
}
for j := len(ak.minus) - 1; j >= 0; j-- {
b = append(b, ak.minus[j])
}
} else {
for j := len(symbol) - 1; j >= 0; j-- {
b = append(b, symbol[j])
}
}
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
if int(v) < 2 {
if v == 0 {
b = append(b, ak.decimal...)
}
for i := 0; i < 2-int(v); i++ {
b = append(b, '0')
}
}
return b
}
// FmtDateShort returns the short date representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtDateShort(t time.Time) []byte {
b := make([]byte, 0, 32)
if t.Year() > 9 {
b = append(b, strconv.Itoa(t.Year())[2:]...)
} else {
b = append(b, strconv.Itoa(t.Year())[1:]...)
}
b = append(b, []byte{0x2f}...)
if t.Month() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Month()), 10)
b = append(b, []byte{0x2f}...)
if t.Day() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Day()), 10)
return b
}
// FmtDateMedium returns the medium date representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtDateMedium(t time.Time) []byte {
b := make([]byte, 0, 32)
b = strconv.AppendInt(b, int64(t.Year()), 10)
b = append(b, []byte{0x20}...)
b = append(b, ak.monthsAbbreviated[t.Month()]...)
b = append(b, []byte{0x20}...)
b = strconv.AppendInt(b, int64(t.Day()), 10)
return b
}
// FmtDateLong returns the long date representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtDateLong(t time.Time) []byte {
b := make([]byte, 0, 32)
b = strconv.AppendInt(b, int64(t.Year()), 10)
b = append(b, []byte{0x20}...)
b = append(b, ak.monthsWide[t.Month()]...)
b = append(b, []byte{0x20}...)
b = strconv.AppendInt(b, int64(t.Day()), 10)
return b
}
// FmtDateFull returns the full date representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtDateFull(t time.Time) []byte {
b := make([]byte, 0, 32)
b = append(b, ak.daysWide[t.Day()]...)
b = append(b, []byte{0x2c, 0x20}...)
b = strconv.AppendInt(b, int64(t.Year()), 10)
b = append(b, []byte{0x20}...)
b = append(b, ak.monthsWide[t.Month()]...)
b = append(b, []byte{0x20}...)
if t.Day() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Day()), 10)
return b
}
// FmtTimeShort returns the short time representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtTimeShort(t time.Time) []byte {
b := make([]byte, 0, 32)
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, ak.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, []byte{0x20}...)
if t.Hour() < 12 {
b = append(b, ak.periodsAbbreviated[0]...)
} else {
b = append(b, ak.periodsAbbreviated[1]...)
}
return b
}
// FmtTimeMedium returns the medium time representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtTimeMedium(t time.Time) []byte {
b := make([]byte, 0, 32)
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, ak.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, ak.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20}...)
if t.Hour() < 12 {
b = append(b, ak.periodsAbbreviated[0]...)
} else {
b = append(b, ak.periodsAbbreviated[1]...)
}
return b
}
// FmtTimeLong returns the long time representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtTimeLong(t time.Time) []byte {
b := make([]byte, 0, 32)
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, ak.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, ak.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20}...)
if t.Hour() < 12 {
b = append(b, ak.periodsAbbreviated[0]...)
} else {
b = append(b, ak.periodsAbbreviated[1]...)
}
b = append(b, []byte{0x20}...)
tz, _ := t.Zone()
b = append(b, tz...)
return b
}
// FmtTimeFull returns the full time representation of 't' for 'ak_GH'
// returned as a []byte just in case the caller wishes to add more and can help
// avoid allocations; otherwise just cast as string.
func (ak *ak_GH) FmtTimeFull(t time.Time) []byte {
b := make([]byte, 0, 32)
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, ak.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, ak.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20}...)
if t.Hour() < 12 {
b = append(b, ak.periodsAbbreviated[0]...)
} else {
b = append(b, ak.periodsAbbreviated[1]...)
}
b = append(b, []byte{0x20}...)
tz, _ := t.Zone()
b = append(b, tz...)
return b
}
|