1 package kab
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 kab 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 &kab{
45 locale: "kab",
46 pluralsCardinal: []locales.PluralRule{2, 6},
47 pluralsOrdinal: nil,
48 pluralsRange: nil,
49 decimal: ",",
50 group: " ",
51 minus: "-",
52 percent: "%",
53 perMille: "‰",
54 timeSeparator: ":",
55 inifinity: "∞",
56 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$AR", "ATS", "$AU", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "FB", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "$BM", "$BN", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "$BS", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "$BZ", "$CA", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "$CL", "CNH", "CNX", "CNY", "$CO", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "£CY", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DA", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "$FJ", "£FK", "F", "£GB", "GEK", "GEL", "GHC", "GHS", "£GI", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "£IE", "£IL", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "₤IT", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "£LB", "LKR", "LRD", "lLS", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "fMA", "MCF", "MDC", "MDL", "MGA", "Fmg", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MRU", "MTL", "£MT", "MUR", "MVP", "MVR", "MWK", "$MX", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "$NA", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$NZ", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "$RH", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "$SB", "SCR", "SDD", "SDG", "SDP", "SEK", "$SG", "SHP", "SIT", "SKK", "SLL", "SOS", "$SR", "SRG", "SSP", "STD", "Db", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "$TT", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$US", "USN", "USS", "UYI", "UYP", "$UY", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WS$", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "DTS", "XEU", "XFO", "XFU", "CFA", "XPD", "FCFP", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
57 monthsAbbreviated: []string{"", "Yen", "Fur", "Meɣ", "Yeb", "May", "Yun", "Yul", "Ɣuc", "Cte", "Tub", "Nun", "Duǧ"},
58 monthsNarrow: []string{"", "Y", "F", "Ɣ", "B", "M", "N", "L", "C", "T", "R", "W", "D"},
59 monthsWide: []string{"", "Yennayer", "Fuṛar", "Meɣres", "Yebrir", "Mayyu", "Yunyu", "Yulyu", "Ɣuct", "Ctembeṛ", "Tubeṛ", "Nunembeṛ", "Duǧembeṛ"},
60 daysAbbreviated: []string{"Yan", "San", "Kraḍ", "Kuẓ", "Sam", "Sḍis", "Say"},
61 daysNarrow: []string{"C", "R", "A", "H", "M", "S", "D"},
62 daysShort: []string{"Cr", "Ri", "Ra", "Hd", "Mh", "Sm", "Sd"},
63 daysWide: []string{"Yanass", "Sanass", "Kraḍass", "Kuẓass", "Samass", "Sḍisass", "Sayass"},
64 periodsAbbreviated: []string{"n tufat", "n tmeddit"},
65 periodsNarrow: []string{"f", "m"},
66 periodsWide: []string{"n tufat", "n tmeddit"},
67 erasAbbreviated: []string{"snd. T.Ɛ", "sld. T.Ɛ"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"send talalit n Ɛisa", "seld talalit n Ɛisa"},
70 timezones: map[string]string{"ACDT": "Akud n Unebdu n Ustralya Talemmast", "ACST": "Akud Amagnu n Ustralya Talemmast", "ACWDT": "Akud n Unebdu n Tlemmast n Umalu n Ustṛalya", "ACWST": "Akud Amagnu n Tlemmast n Umalu n Ustṛalya", "ADT": "Akud Aṭlasan n Unebdu", "AEDT": "Akud n Unebdu n Ustṛalya n Usammar", "AEST": "Akud Amagnu n Ustṛalya n Usammar", "AKDT": "Akud n Unebdu n Alaska", "AKST": "Akud Amagnu n Alaska", "ARST": "Akud n Unebdu n Arjuntin", "ART": "Akud Amagnu n Arjuntin", "AST": "Akud Amagnu Aṭlasan", "AWDT": "Akud n Unebdu Ustṛalya n Umalu", "AWST": "Akud Amagnu n Ustṛalya n Umalu", "BOT": "Akud n Bulivi", "BT": "Akud n Butan", "CAT": "Akud n tefriqt talemmast", "CDT": "Akud n Unebdu n Tlemmast n Marikan", "CHADT": "Akud n Unebdu Catham", "CHAST": "Akud Amagnu n Catham", "CLST": "Akud n Unebdu n Cili", "CLT": "Akud Amagnu n Cili", "COST": "Akud n Unebdu n Kulumbya", "COT": "Akud Amagnu n Kulumbya", "CST": "Akud Amagnu n Tlemmast n Marikan", "ChST": "Akud Amagnu n Camuṛṛu", "EAT": "Akud n tefriqt n usammar", "ECT": "Akud n Ikwaṭur", "EDT": "Akud n Unebdu n Usammar Agafa n Marikan", "EST": "Akud Amagnu n Usammar Agafa n Marikan", "GFT": "Akud n Gwiyan Tafṛansist", "GMT": "Akud alemmas n Greenwich", "GST": "Akud Amagnu n Gulf", "GYT": "Akud n Gwiyan", "HADT": "Akud n Unebu n Haway-Aliwsyan", "HAST": "Akud Amagnu n Haway-Aliwsyan", "HAT": "Akud n Unebdu n Wakal Amaynut", "HECU": "Akud n Unebdu n Kuba", "HEEG": "Akud n Unebdu n Grinland n Usammar", "HENOMX": "Akud n Unebdu n Ugafa Amalu n Miksik", "HEOG": "Akud n Unebdu n Grinland n Umalu", "HEPM": "Akud n Unebdu n San Pyir & Miklun", "HEPMX": "Akud Amelwi n Unebdu n Miksik", "HKST": "Akud n Unebdu n Hung Kung", "HKT": "Akud Amagnu n Hung Kung", "HNCU": "Akud Amagnu n Kuba", "HNEG": "Akud Amagnu n Grinland n Usammar", "HNNOMX": "Akud Amagnu n Ugafa Amalu n Miksik", "HNOG": "Akud Amagnu n Grinland n Umalu", "HNPM": "Akud Amagnu n San Pyir & Miklun", "HNPMX": "Akud amagnu Amelwi n Miksik", "HNT": "Akud Amagnu n Wakal Amaynut", "IST": "Akud Amagnu n Hend", "JDT": "Akud n Unebdu n Japun", "JST": "Akud Amagnu n Japun", "LHDT": "Akud n Unebdu n Lord Howe", "LHST": "Akud Amagnu n Lord Howe", "MDT": "Akud n Unebdu n Idurar n Marikan", "MESZ": "Akud n unebdu n Turuft Talemmast", "MEZ": "Akud amagnu n Turuft Talemmast", "MST": "Akud Amagnu n Idurar n Marikan", "MYT": "Akud n Malizya", "NZDT": "Akud n Unebdu Ziland Tamaynut", "NZST": "Akud Amagnu n Ziland Tamaynut", "OESZ": "Akud n unebdu n Turuft n Usammar", "OEZ": "Akud amagnu n Turuft n Usammar", "PDT": "Akud Amelwi n Unebdu n Marikan n Ugafa", "PST": "Akud Amelwi Amagnu n Marikan n Ugafa", "SAST": "Akud amagnu n tefriqt n unẓul", "SGT": "Akud Amagnu n Sangapur", "SRT": "Akud n Surinam", "TMST": "Akud n Unebdu n Ṭurkmanistan", "TMT": "Akud Amagnu n Ṭurkmanistan", "UYST": "Akud n Unebdu n Urugway", "UYT": "Akud amagnu n Urugway", "VET": "Akud n Vinizwila", "WARST": "Akud n Unebdu n Arjuntin n Usammar", "WART": "Akud Amagnu n Arjuntin n Usammar", "WAST": "Akud n unebdu n tefriqt n umalu", "WAT": "Akud amagnu n tefriqt n umalu", "WESZ": "Akud n unebdu turuft n umalu", "WEZ": "Akud amagnu n turuft n umalu", "WIB": "Akud n Umalu n Indunisya", "WIT": "Akud n Usammar n Indunisya", "WITA": "Akud n Tlemmast n Indunisya", "∅∅∅": "Akud n Unebdu n Bṛazilya"},
71 }
72 }
73
74
75 func (kab *kab) Locale() string {
76 return kab.locale
77 }
78
79
80 func (kab *kab) PluralsCardinal() []locales.PluralRule {
81 return kab.pluralsCardinal
82 }
83
84
85 func (kab *kab) PluralsOrdinal() []locales.PluralRule {
86 return kab.pluralsOrdinal
87 }
88
89
90 func (kab *kab) PluralsRange() []locales.PluralRule {
91 return kab.pluralsRange
92 }
93
94
95 func (kab *kab) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97 n := math.Abs(num)
98 i := int64(n)
99
100 if i == 0 || i == 1 {
101 return locales.PluralRuleOne
102 }
103
104 return locales.PluralRuleOther
105 }
106
107
108 func (kab *kab) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
109 return locales.PluralRuleUnknown
110 }
111
112
113 func (kab *kab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
114 return locales.PluralRuleUnknown
115 }
116
117
118 func (kab *kab) MonthAbbreviated(month time.Month) string {
119 return kab.monthsAbbreviated[month]
120 }
121
122
123 func (kab *kab) MonthsAbbreviated() []string {
124 return kab.monthsAbbreviated[1:]
125 }
126
127
128 func (kab *kab) MonthNarrow(month time.Month) string {
129 return kab.monthsNarrow[month]
130 }
131
132
133 func (kab *kab) MonthsNarrow() []string {
134 return kab.monthsNarrow[1:]
135 }
136
137
138 func (kab *kab) MonthWide(month time.Month) string {
139 return kab.monthsWide[month]
140 }
141
142
143 func (kab *kab) MonthsWide() []string {
144 return kab.monthsWide[1:]
145 }
146
147
148 func (kab *kab) WeekdayAbbreviated(weekday time.Weekday) string {
149 return kab.daysAbbreviated[weekday]
150 }
151
152
153 func (kab *kab) WeekdaysAbbreviated() []string {
154 return kab.daysAbbreviated
155 }
156
157
158 func (kab *kab) WeekdayNarrow(weekday time.Weekday) string {
159 return kab.daysNarrow[weekday]
160 }
161
162
163 func (kab *kab) WeekdaysNarrow() []string {
164 return kab.daysNarrow
165 }
166
167
168 func (kab *kab) WeekdayShort(weekday time.Weekday) string {
169 return kab.daysShort[weekday]
170 }
171
172
173 func (kab *kab) WeekdaysShort() []string {
174 return kab.daysShort
175 }
176
177
178 func (kab *kab) WeekdayWide(weekday time.Weekday) string {
179 return kab.daysWide[weekday]
180 }
181
182
183 func (kab *kab) WeekdaysWide() []string {
184 return kab.daysWide
185 }
186
187
188 func (kab *kab) Decimal() string {
189 return kab.decimal
190 }
191
192
193 func (kab *kab) Group() string {
194 return kab.group
195 }
196
197
198 func (kab *kab) Minus() string {
199 return kab.minus
200 }
201
202
203 func (kab *kab) FmtNumber(num float64, v uint64) string {
204
205 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
207 count := 0
208 inWhole := v == 0
209 b := make([]byte, 0, l)
210
211 for i := len(s) - 1; i >= 0; i-- {
212
213 if s[i] == '.' {
214 b = append(b, kab.decimal[0])
215 inWhole = true
216 continue
217 }
218
219 if inWhole {
220 if count == 3 {
221 for j := len(kab.group) - 1; j >= 0; j-- {
222 b = append(b, kab.group[j])
223 }
224 count = 1
225 } else {
226 count++
227 }
228 }
229
230 b = append(b, s[i])
231 }
232
233 if num < 0 {
234 b = append(b, kab.minus[0])
235 }
236
237
238 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
239 b[i], b[j] = b[j], b[i]
240 }
241
242 return string(b)
243 }
244
245
246
247 func (kab *kab) FmtPercent(num float64, v uint64) string {
248 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
249 l := len(s) + 3
250 b := make([]byte, 0, l)
251
252 for i := len(s) - 1; i >= 0; i-- {
253
254 if s[i] == '.' {
255 b = append(b, kab.decimal[0])
256 continue
257 }
258
259 b = append(b, s[i])
260 }
261
262 if num < 0 {
263 b = append(b, kab.minus[0])
264 }
265
266
267 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
268 b[i], b[j] = b[j], b[i]
269 }
270
271 b = append(b, kab.percent...)
272
273 return string(b)
274 }
275
276
277 func (kab *kab) FmtCurrency(num float64, v uint64, currency currency.Type) string {
278
279 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
280 symbol := kab.currencies[currency]
281 l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3
282 count := 0
283 inWhole := v == 0
284 b := make([]byte, 0, l)
285
286 for i := len(s) - 1; i >= 0; i-- {
287
288 if s[i] == '.' {
289 b = append(b, kab.decimal[0])
290 inWhole = true
291 continue
292 }
293
294 if inWhole {
295 if count == 3 {
296 for j := len(kab.group) - 1; j >= 0; j-- {
297 b = append(b, kab.group[j])
298 }
299 count = 1
300 } else {
301 count++
302 }
303 }
304
305 b = append(b, s[i])
306 }
307
308 if num < 0 {
309 b = append(b, kab.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, kab.decimal...)
321 }
322
323 for i := 0; i < 2-int(v); i++ {
324 b = append(b, '0')
325 }
326 }
327
328 b = append(b, symbol...)
329
330 return string(b)
331 }
332
333
334
335 func (kab *kab) FmtAccounting(num float64, v uint64, currency currency.Type) string {
336
337 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
338 symbol := kab.currencies[currency]
339 l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3
340 count := 0
341 inWhole := v == 0
342 b := make([]byte, 0, l)
343
344 for i := len(s) - 1; i >= 0; i-- {
345
346 if s[i] == '.' {
347 b = append(b, kab.decimal[0])
348 inWhole = true
349 continue
350 }
351
352 if inWhole {
353 if count == 3 {
354 for j := len(kab.group) - 1; j >= 0; j-- {
355 b = append(b, kab.group[j])
356 }
357 count = 1
358 } else {
359 count++
360 }
361 }
362
363 b = append(b, s[i])
364 }
365
366 if num < 0 {
367
368 b = append(b, kab.minus[0])
369
370 }
371
372
373 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
374 b[i], b[j] = b[j], b[i]
375 }
376
377 if int(v) < 2 {
378
379 if v == 0 {
380 b = append(b, kab.decimal...)
381 }
382
383 for i := 0; i < 2-int(v); i++ {
384 b = append(b, '0')
385 }
386 }
387
388 if num < 0 {
389 b = append(b, symbol...)
390 } else {
391
392 b = append(b, symbol...)
393 }
394
395 return string(b)
396 }
397
398
399 func (kab *kab) FmtDateShort(t time.Time) string {
400
401 b := make([]byte, 0, 32)
402
403 b = strconv.AppendInt(b, int64(t.Day()), 10)
404 b = append(b, []byte{0x2f}...)
405 b = strconv.AppendInt(b, int64(t.Month()), 10)
406 b = append(b, []byte{0x2f}...)
407
408 if t.Year() > 0 {
409 b = strconv.AppendInt(b, int64(t.Year()), 10)
410 } else {
411 b = strconv.AppendInt(b, int64(-t.Year()), 10)
412 }
413
414 return string(b)
415 }
416
417
418 func (kab *kab) FmtDateMedium(t time.Time) string {
419
420 b := make([]byte, 0, 32)
421
422 b = strconv.AppendInt(b, int64(t.Day()), 10)
423 b = append(b, []byte{0x20}...)
424 b = append(b, kab.monthsAbbreviated[t.Month()]...)
425 b = append(b, []byte{0x2c, 0x20}...)
426
427 if t.Year() > 0 {
428 b = strconv.AppendInt(b, int64(t.Year()), 10)
429 } else {
430 b = strconv.AppendInt(b, int64(-t.Year()), 10)
431 }
432
433 return string(b)
434 }
435
436
437 func (kab *kab) FmtDateLong(t time.Time) string {
438
439 b := make([]byte, 0, 32)
440
441 b = strconv.AppendInt(b, int64(t.Day()), 10)
442 b = append(b, []byte{0x20}...)
443 b = append(b, kab.monthsWide[t.Month()]...)
444 b = append(b, []byte{0x20}...)
445
446 if t.Year() > 0 {
447 b = strconv.AppendInt(b, int64(t.Year()), 10)
448 } else {
449 b = strconv.AppendInt(b, int64(-t.Year()), 10)
450 }
451
452 return string(b)
453 }
454
455
456 func (kab *kab) FmtDateFull(t time.Time) string {
457
458 b := make([]byte, 0, 32)
459
460 b = append(b, kab.daysWide[t.Weekday()]...)
461 b = append(b, []byte{0x20}...)
462 b = strconv.AppendInt(b, int64(t.Day()), 10)
463 b = append(b, []byte{0x20}...)
464 b = append(b, kab.monthsWide[t.Month()]...)
465 b = append(b, []byte{0x20}...)
466
467 if t.Year() > 0 {
468 b = strconv.AppendInt(b, int64(t.Year()), 10)
469 } else {
470 b = strconv.AppendInt(b, int64(-t.Year()), 10)
471 }
472
473 return string(b)
474 }
475
476
477 func (kab *kab) FmtTimeShort(t time.Time) string {
478
479 b := make([]byte, 0, 32)
480
481 h := t.Hour()
482
483 if h > 12 {
484 h -= 12
485 }
486
487 b = strconv.AppendInt(b, int64(h), 10)
488 b = append(b, kab.timeSeparator...)
489
490 if t.Minute() < 10 {
491 b = append(b, '0')
492 }
493
494 b = strconv.AppendInt(b, int64(t.Minute()), 10)
495 b = append(b, []byte{0x20}...)
496
497 if t.Hour() < 12 {
498 b = append(b, kab.periodsAbbreviated[0]...)
499 } else {
500 b = append(b, kab.periodsAbbreviated[1]...)
501 }
502
503 return string(b)
504 }
505
506
507 func (kab *kab) FmtTimeMedium(t time.Time) string {
508
509 b := make([]byte, 0, 32)
510
511 h := t.Hour()
512
513 if h > 12 {
514 h -= 12
515 }
516
517 b = strconv.AppendInt(b, int64(h), 10)
518 b = append(b, kab.timeSeparator...)
519
520 if t.Minute() < 10 {
521 b = append(b, '0')
522 }
523
524 b = strconv.AppendInt(b, int64(t.Minute()), 10)
525 b = append(b, kab.timeSeparator...)
526
527 if t.Second() < 10 {
528 b = append(b, '0')
529 }
530
531 b = strconv.AppendInt(b, int64(t.Second()), 10)
532 b = append(b, []byte{0x20}...)
533
534 if t.Hour() < 12 {
535 b = append(b, kab.periodsAbbreviated[0]...)
536 } else {
537 b = append(b, kab.periodsAbbreviated[1]...)
538 }
539
540 return string(b)
541 }
542
543
544 func (kab *kab) FmtTimeLong(t time.Time) string {
545
546 b := make([]byte, 0, 32)
547
548 h := t.Hour()
549
550 if h > 12 {
551 h -= 12
552 }
553
554 b = strconv.AppendInt(b, int64(h), 10)
555 b = append(b, kab.timeSeparator...)
556
557 if t.Minute() < 10 {
558 b = append(b, '0')
559 }
560
561 b = strconv.AppendInt(b, int64(t.Minute()), 10)
562 b = append(b, kab.timeSeparator...)
563
564 if t.Second() < 10 {
565 b = append(b, '0')
566 }
567
568 b = strconv.AppendInt(b, int64(t.Second()), 10)
569 b = append(b, []byte{0x20}...)
570
571 if t.Hour() < 12 {
572 b = append(b, kab.periodsAbbreviated[0]...)
573 } else {
574 b = append(b, kab.periodsAbbreviated[1]...)
575 }
576
577 b = append(b, []byte{0x20}...)
578
579 tz, _ := t.Zone()
580 b = append(b, tz...)
581
582 return string(b)
583 }
584
585
586 func (kab *kab) FmtTimeFull(t time.Time) string {
587
588 b := make([]byte, 0, 32)
589
590 h := t.Hour()
591
592 if h > 12 {
593 h -= 12
594 }
595
596 b = strconv.AppendInt(b, int64(h), 10)
597 b = append(b, kab.timeSeparator...)
598
599 if t.Minute() < 10 {
600 b = append(b, '0')
601 }
602
603 b = strconv.AppendInt(b, int64(t.Minute()), 10)
604 b = append(b, kab.timeSeparator...)
605
606 if t.Second() < 10 {
607 b = append(b, '0')
608 }
609
610 b = strconv.AppendInt(b, int64(t.Second()), 10)
611 b = append(b, []byte{0x20}...)
612
613 if t.Hour() < 12 {
614 b = append(b, kab.periodsAbbreviated[0]...)
615 } else {
616 b = append(b, kab.periodsAbbreviated[1]...)
617 }
618
619 b = append(b, []byte{0x20}...)
620
621 tz, _ := t.Zone()
622
623 if btz, ok := kab.timezones[tz]; ok {
624 b = append(b, btz...)
625 } else {
626 b = append(b, tz...)
627 }
628
629 return string(b)
630 }
631
View as plain text