OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-playground / locales / ckb / ckb.go
1 package ckb
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 ckb 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         percentSuffix          string
22         perMille               string
23         timeSeparator          string
24         inifinity              string
25         currencies             []string // idx = enum of currency code
26         currencyPositiveSuffix string
27         currencyNegativeSuffix string
28         monthsAbbreviated      []string
29         monthsNarrow           []string
30         monthsWide             []string
31         daysAbbreviated        []string
32         daysNarrow             []string
33         daysShort              []string
34         daysWide               []string
35         periodsAbbreviated     []string
36         periodsNarrow          []string
37         periodsShort           []string
38         periodsWide            []string
39         erasAbbreviated        []string
40         erasNarrow             []string
41         erasWide               []string
42         timezones              map[string]string
43 }
44
45 // New returns a new instance of translator for the 'ckb' locale
46 func New() locales.Translator {
47         return &ckb{
48                 locale:                 "ckb",
49                 pluralsCardinal:        []locales.PluralRule{2, 6},
50                 pluralsOrdinal:         nil,
51                 pluralsRange:           nil,
52                 decimal:                "٫",
53                 group:                  "٬",
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", "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", "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", "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", "UZS", "VEB", "VEF", "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                 percentSuffix:          " ",
60                 currencyPositiveSuffix: " ",
61                 currencyNegativeSuffix: " ",
62                 monthsAbbreviated:      []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"},
63                 monthsNarrow:           []string{"", "ک", "ش", "ئ", "ن", "ئ", "ح", "ت", "ئ", "ئ", "ت", "ت", "ک"},
64                 monthsWide:             []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"},
65                 daysAbbreviated:        []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"},
66                 daysNarrow:             []string{"ی", "د", "س", "چ", "پ", "ھ", "ش"},
67                 daysShort:              []string{"١ش", "٢ش", "٣ش", "٤ش", "٥ش", "ھ", "ش"},
68                 daysWide:               []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"},
69                 periodsAbbreviated:     []string{"ب.ن", "د.ن"},
70                 periodsNarrow:          []string{"ب.ن", "د.ن"},
71                 periodsWide:            []string{"ب.ن", "د.ن"},
72                 erasAbbreviated:        []string{"پێش زایین", "زایینی"},
73                 erasNarrow:             []string{"پ.ن", "ز"},
74                 erasWide:               []string{"پێش زایین", "زایینی"},
75                 timezones:              map[string]string{"EDT": "EDT", "AKST": "AKST", "ACWST": "ACWST", "CST": "CST", "IST": "IST", "GYT": "GYT", "PDT": "PDT", "MDT": "MDT", "CHADT": "CHADT", "BOT": "BOT", "ARST": "ARST", "WAT": "WAT", "CLST": "CLST", "∅∅∅": "∅∅∅", "HEPMX": "HEPMX", "WITA": "WITA", "WAST": "WAST", "COT": "COT", "HNT": "HNT", "CAT": "CAT", "WIT": "WIT", "AWDT": "AWDT", "UYT": "UYT", "NZST": "NZST", "LHST": "LHST", "WARST": "WARST", "CLT": "CLT", "HNPMX": "HNPMX", "HEPM": "HEPM", "HAST": "HAST", "NZDT": "NZDT", "ECT": "ECT", "SRT": "SRT", "HNNOMX": "HNNOMX", "JDT": "JDT", "SAST": "SAST", "HKT": "HKT", "COST": "COST", "ChST": "ChST", "UYST": "UYST", "GMT": "GMT", "CHAST": "CHAST", "AWST": "AWST", "OESZ": "OESZ", "EAT": "EAT", "HAT": "HAT", "ACST": "ACST", "AKDT": "AKDT", "LHDT": "LHDT", "HNOG": "HNOG", "HNPM": "HNPM", "PST": "PST", "OEZ": "OEZ", "ART": "ART", "HADT": "HADT", "TMT": "TMT", "AEDT": "AEDT", "TMST": "TMST", "MESZ": "MESZ", "AEST": "AEST", "SGT": "SGT", "HNCU": "HNCU", "BT": "BT", "MST": "MST", "HENOMX": "HENOMX", "HEEG": "HEEG", "WESZ": "WESZ", "HECU": "HECU", "VET": "VET", "HEOG": "HEOG", "ADT": "ADT", "HNEG": "HNEG", "HKST": "HKST", "GFT": "GFT", "WEZ": "WEZ", "WART": "WART", "MEZ": "MEZ", "AST": "AST", "EST": "EST", "CDT": "CDT", "ACWDT": "ACWDT", "MYT": "MYT", "JST": "JST", "ACDT": "ACDT", "WIB": "WIB"},
76         }
77 }
78
79 // Locale returns the current translators string locale
80 func (ckb *ckb) Locale() string {
81         return ckb.locale
82 }
83
84 // PluralsCardinal returns the list of cardinal plural rules associated with 'ckb'
85 func (ckb *ckb) PluralsCardinal() []locales.PluralRule {
86         return ckb.pluralsCardinal
87 }
88
89 // PluralsOrdinal returns the list of ordinal plural rules associated with 'ckb'
90 func (ckb *ckb) PluralsOrdinal() []locales.PluralRule {
91         return ckb.pluralsOrdinal
92 }
93
94 // PluralsRange returns the list of range plural rules associated with 'ckb'
95 func (ckb *ckb) PluralsRange() []locales.PluralRule {
96         return ckb.pluralsRange
97 }
98
99 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ckb'
100 func (ckb *ckb) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
101
102         n := math.Abs(num)
103
104         if n == 1 {
105                 return locales.PluralRuleOne
106         }
107
108         return locales.PluralRuleOther
109 }
110
111 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ckb'
112 func (ckb *ckb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113         return locales.PluralRuleUnknown
114 }
115
116 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ckb'
117 func (ckb *ckb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
118         return locales.PluralRuleUnknown
119 }
120
121 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
122 func (ckb *ckb) MonthAbbreviated(month time.Month) string {
123         return ckb.monthsAbbreviated[month]
124 }
125
126 // MonthsAbbreviated returns the locales abbreviated months
127 func (ckb *ckb) MonthsAbbreviated() []string {
128         return ckb.monthsAbbreviated[1:]
129 }
130
131 // MonthNarrow returns the locales narrow month given the 'month' provided
132 func (ckb *ckb) MonthNarrow(month time.Month) string {
133         return ckb.monthsNarrow[month]
134 }
135
136 // MonthsNarrow returns the locales narrow months
137 func (ckb *ckb) MonthsNarrow() []string {
138         return ckb.monthsNarrow[1:]
139 }
140
141 // MonthWide returns the locales wide month given the 'month' provided
142 func (ckb *ckb) MonthWide(month time.Month) string {
143         return ckb.monthsWide[month]
144 }
145
146 // MonthsWide returns the locales wide months
147 func (ckb *ckb) MonthsWide() []string {
148         return ckb.monthsWide[1:]
149 }
150
151 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
152 func (ckb *ckb) WeekdayAbbreviated(weekday time.Weekday) string {
153         return ckb.daysAbbreviated[weekday]
154 }
155
156 // WeekdaysAbbreviated returns the locales abbreviated weekdays
157 func (ckb *ckb) WeekdaysAbbreviated() []string {
158         return ckb.daysAbbreviated
159 }
160
161 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
162 func (ckb *ckb) WeekdayNarrow(weekday time.Weekday) string {
163         return ckb.daysNarrow[weekday]
164 }
165
166 // WeekdaysNarrow returns the locales narrow weekdays
167 func (ckb *ckb) WeekdaysNarrow() []string {
168         return ckb.daysNarrow
169 }
170
171 // WeekdayShort returns the locales short weekday given the 'weekday' provided
172 func (ckb *ckb) WeekdayShort(weekday time.Weekday) string {
173         return ckb.daysShort[weekday]
174 }
175
176 // WeekdaysShort returns the locales short weekdays
177 func (ckb *ckb) WeekdaysShort() []string {
178         return ckb.daysShort
179 }
180
181 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
182 func (ckb *ckb) WeekdayWide(weekday time.Weekday) string {
183         return ckb.daysWide[weekday]
184 }
185
186 // WeekdaysWide returns the locales wide weekdays
187 func (ckb *ckb) WeekdaysWide() []string {
188         return ckb.daysWide
189 }
190
191 // Decimal returns the decimal point of number
192 func (ckb *ckb) Decimal() string {
193         return ckb.decimal
194 }
195
196 // Group returns the group of number
197 func (ckb *ckb) Group() string {
198         return ckb.group
199 }
200
201 // Group returns the minus sign of number
202 func (ckb *ckb) Minus() string {
203         return ckb.minus
204 }
205
206 // FmtNumber returns 'num' with digits/precision of 'v' for 'ckb' and handles both Whole and Real numbers based on 'v'
207 func (ckb *ckb) FmtNumber(num float64, v uint64) string {
208
209         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
210         l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
211         count := 0
212         inWhole := v == 0
213         b := make([]byte, 0, l)
214
215         for i := len(s) - 1; i >= 0; i-- {
216
217                 if s[i] == '.' {
218                         for j := len(ckb.decimal) - 1; j >= 0; j-- {
219                                 b = append(b, ckb.decimal[j])
220                         }
221                         inWhole = true
222                         continue
223                 }
224
225                 if inWhole {
226                         if count == 3 {
227                                 for j := len(ckb.group) - 1; j >= 0; j-- {
228                                         b = append(b, ckb.group[j])
229                                 }
230                                 count = 1
231                         } else {
232                                 count++
233                         }
234                 }
235
236                 b = append(b, s[i])
237         }
238
239         if num < 0 {
240                 b = append(b, ckb.minus[0])
241         }
242
243         // reverse
244         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
245                 b[i], b[j] = b[j], b[i]
246         }
247
248         return string(b)
249 }
250
251 // FmtPercent returns 'num' with digits/precision of 'v' for 'ckb' and handles both Whole and Real numbers based on 'v'
252 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
253 func (ckb *ckb) FmtPercent(num float64, v uint64) string {
254         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
255         l := len(s) + 6
256         b := make([]byte, 0, l)
257
258         for i := len(s) - 1; i >= 0; i-- {
259
260                 if s[i] == '.' {
261                         for j := len(ckb.decimal) - 1; j >= 0; j-- {
262                                 b = append(b, ckb.decimal[j])
263                         }
264                         continue
265                 }
266
267                 b = append(b, s[i])
268         }
269
270         if num < 0 {
271                 b = append(b, ckb.minus[0])
272         }
273
274         // reverse
275         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
276                 b[i], b[j] = b[j], b[i]
277         }
278
279         b = append(b, ckb.percentSuffix...)
280
281         b = append(b, ckb.percent...)
282
283         return string(b)
284 }
285
286 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ckb'
287 func (ckb *ckb) FmtCurrency(num float64, v uint64, currency currency.Type) string {
288
289         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
290         symbol := ckb.currencies[currency]
291         l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
292         count := 0
293         inWhole := v == 0
294         b := make([]byte, 0, l)
295
296         for i := len(s) - 1; i >= 0; i-- {
297
298                 if s[i] == '.' {
299                         for j := len(ckb.decimal) - 1; j >= 0; j-- {
300                                 b = append(b, ckb.decimal[j])
301                         }
302                         inWhole = true
303                         continue
304                 }
305
306                 if inWhole {
307                         if count == 3 {
308                                 for j := len(ckb.group) - 1; j >= 0; j-- {
309                                         b = append(b, ckb.group[j])
310                                 }
311                                 count = 1
312                         } else {
313                                 count++
314                         }
315                 }
316
317                 b = append(b, s[i])
318         }
319
320         if num < 0 {
321                 b = append(b, ckb.minus[0])
322         }
323
324         // reverse
325         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
326                 b[i], b[j] = b[j], b[i]
327         }
328
329         if int(v) < 2 {
330
331                 if v == 0 {
332                         b = append(b, ckb.decimal...)
333                 }
334
335                 for i := 0; i < 2-int(v); i++ {
336                         b = append(b, '0')
337                 }
338         }
339
340         b = append(b, ckb.currencyPositiveSuffix...)
341
342         b = append(b, symbol...)
343
344         return string(b)
345 }
346
347 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ckb'
348 // in accounting notation.
349 func (ckb *ckb) FmtAccounting(num float64, v uint64, currency currency.Type) string {
350
351         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
352         symbol := ckb.currencies[currency]
353         l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
354         count := 0
355         inWhole := v == 0
356         b := make([]byte, 0, l)
357
358         for i := len(s) - 1; i >= 0; i-- {
359
360                 if s[i] == '.' {
361                         for j := len(ckb.decimal) - 1; j >= 0; j-- {
362                                 b = append(b, ckb.decimal[j])
363                         }
364                         inWhole = true
365                         continue
366                 }
367
368                 if inWhole {
369                         if count == 3 {
370                                 for j := len(ckb.group) - 1; j >= 0; j-- {
371                                         b = append(b, ckb.group[j])
372                                 }
373                                 count = 1
374                         } else {
375                                 count++
376                         }
377                 }
378
379                 b = append(b, s[i])
380         }
381
382         if num < 0 {
383
384                 b = append(b, ckb.minus[0])
385
386         }
387
388         // reverse
389         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
390                 b[i], b[j] = b[j], b[i]
391         }
392
393         if int(v) < 2 {
394
395                 if v == 0 {
396                         b = append(b, ckb.decimal...)
397                 }
398
399                 for i := 0; i < 2-int(v); i++ {
400                         b = append(b, '0')
401                 }
402         }
403
404         if num < 0 {
405                 b = append(b, ckb.currencyNegativeSuffix...)
406                 b = append(b, symbol...)
407         } else {
408
409                 b = append(b, ckb.currencyPositiveSuffix...)
410                 b = append(b, symbol...)
411         }
412
413         return string(b)
414 }
415
416 // FmtDateShort returns the short date representation of 't' for 'ckb'
417 func (ckb *ckb) FmtDateShort(t time.Time) string {
418
419         b := make([]byte, 0, 32)
420
421         if t.Year() > 0 {
422                 b = strconv.AppendInt(b, int64(t.Year()), 10)
423         } else {
424                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
425         }
426
427         b = append(b, []byte{0x2d}...)
428
429         if t.Month() < 10 {
430                 b = append(b, '0')
431         }
432
433         b = strconv.AppendInt(b, int64(t.Month()), 10)
434
435         b = append(b, []byte{0x2d}...)
436
437         if t.Day() < 10 {
438                 b = append(b, '0')
439         }
440
441         b = strconv.AppendInt(b, int64(t.Day()), 10)
442
443         return string(b)
444 }
445
446 // FmtDateMedium returns the medium date representation of 't' for 'ckb'
447 func (ckb *ckb) FmtDateMedium(t time.Time) string {
448
449         b := make([]byte, 0, 32)
450
451         if t.Year() > 0 {
452                 b = strconv.AppendInt(b, int64(t.Year()), 10)
453         } else {
454                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
455         }
456
457         b = append(b, []byte{0x20}...)
458         b = append(b, ckb.monthsAbbreviated[t.Month()]...)
459         b = append(b, []byte{0x20}...)
460         b = strconv.AppendInt(b, int64(t.Day()), 10)
461
462         return string(b)
463 }
464
465 // FmtDateLong returns the long date representation of 't' for 'ckb'
466 func (ckb *ckb) FmtDateLong(t time.Time) string {
467
468         b := make([]byte, 0, 32)
469
470         b = strconv.AppendInt(b, int64(t.Day()), 10)
471         b = append(b, []byte{0xdb, 0x8c, 0x20}...)
472         b = append(b, ckb.monthsWide[t.Month()]...)
473         b = append(b, []byte{0xdb, 0x8c, 0x20}...)
474
475         if t.Year() > 0 {
476                 b = strconv.AppendInt(b, int64(t.Year()), 10)
477         } else {
478                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
479         }
480
481         return string(b)
482 }
483
484 // FmtDateFull returns the full date representation of 't' for 'ckb'
485 func (ckb *ckb) FmtDateFull(t time.Time) string {
486
487         b := make([]byte, 0, 32)
488
489         if t.Year() > 0 {
490                 b = strconv.AppendInt(b, int64(t.Year()), 10)
491         } else {
492                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
493         }
494
495         b = append(b, []byte{0x20}...)
496         b = append(b, ckb.monthsWide[t.Month()]...)
497         b = append(b, []byte{0x20}...)
498         b = strconv.AppendInt(b, int64(t.Day()), 10)
499         b = append(b, []byte{0x2c, 0x20}...)
500         b = append(b, ckb.daysWide[t.Weekday()]...)
501
502         return string(b)
503 }
504
505 // FmtTimeShort returns the short time representation of 't' for 'ckb'
506 func (ckb *ckb) FmtTimeShort(t time.Time) string {
507
508         b := make([]byte, 0, 32)
509
510         h := t.Hour()
511
512         if h > 12 {
513                 h -= 12
514         }
515
516         b = strconv.AppendInt(b, int64(h), 10)
517         b = append(b, ckb.timeSeparator...)
518
519         if t.Minute() < 10 {
520                 b = append(b, '0')
521         }
522
523         b = strconv.AppendInt(b, int64(t.Minute()), 10)
524         b = append(b, []byte{0x20}...)
525
526         if t.Hour() < 12 {
527                 b = append(b, ckb.periodsAbbreviated[0]...)
528         } else {
529                 b = append(b, ckb.periodsAbbreviated[1]...)
530         }
531
532         return string(b)
533 }
534
535 // FmtTimeMedium returns the medium time representation of 't' for 'ckb'
536 func (ckb *ckb) FmtTimeMedium(t time.Time) string {
537
538         b := make([]byte, 0, 32)
539
540         h := t.Hour()
541
542         if h > 12 {
543                 h -= 12
544         }
545
546         b = strconv.AppendInt(b, int64(h), 10)
547         b = append(b, ckb.timeSeparator...)
548
549         if t.Minute() < 10 {
550                 b = append(b, '0')
551         }
552
553         b = strconv.AppendInt(b, int64(t.Minute()), 10)
554         b = append(b, ckb.timeSeparator...)
555
556         if t.Second() < 10 {
557                 b = append(b, '0')
558         }
559
560         b = strconv.AppendInt(b, int64(t.Second()), 10)
561         b = append(b, []byte{0x20}...)
562
563         if t.Hour() < 12 {
564                 b = append(b, ckb.periodsAbbreviated[0]...)
565         } else {
566                 b = append(b, ckb.periodsAbbreviated[1]...)
567         }
568
569         return string(b)
570 }
571
572 // FmtTimeLong returns the long time representation of 't' for 'ckb'
573 func (ckb *ckb) FmtTimeLong(t time.Time) string {
574
575         b := make([]byte, 0, 32)
576
577         h := t.Hour()
578
579         if h > 12 {
580                 h -= 12
581         }
582
583         b = strconv.AppendInt(b, int64(h), 10)
584         b = append(b, ckb.timeSeparator...)
585
586         if t.Minute() < 10 {
587                 b = append(b, '0')
588         }
589
590         b = strconv.AppendInt(b, int64(t.Minute()), 10)
591         b = append(b, ckb.timeSeparator...)
592
593         if t.Second() < 10 {
594                 b = append(b, '0')
595         }
596
597         b = strconv.AppendInt(b, int64(t.Second()), 10)
598         b = append(b, []byte{0x20}...)
599
600         if t.Hour() < 12 {
601                 b = append(b, ckb.periodsAbbreviated[0]...)
602         } else {
603                 b = append(b, ckb.periodsAbbreviated[1]...)
604         }
605
606         b = append(b, []byte{0x20}...)
607
608         tz, _ := t.Zone()
609         b = append(b, tz...)
610
611         return string(b)
612 }
613
614 // FmtTimeFull returns the full time representation of 't' for 'ckb'
615 func (ckb *ckb) FmtTimeFull(t time.Time) string {
616
617         b := make([]byte, 0, 32)
618
619         h := t.Hour()
620
621         if h > 12 {
622                 h -= 12
623         }
624
625         b = strconv.AppendInt(b, int64(h), 10)
626         b = append(b, ckb.timeSeparator...)
627
628         if t.Minute() < 10 {
629                 b = append(b, '0')
630         }
631
632         b = strconv.AppendInt(b, int64(t.Minute()), 10)
633         b = append(b, ckb.timeSeparator...)
634
635         if t.Second() < 10 {
636                 b = append(b, '0')
637         }
638
639         b = strconv.AppendInt(b, int64(t.Second()), 10)
640         b = append(b, []byte{0x20}...)
641
642         if t.Hour() < 12 {
643                 b = append(b, ckb.periodsAbbreviated[0]...)
644         } else {
645                 b = append(b, ckb.periodsAbbreviated[1]...)
646         }
647
648         b = append(b, []byte{0x20}...)
649
650         tz, _ := t.Zone()
651
652         if btz, ok := ckb.timezones[tz]; ok {
653                 b = append(b, btz...)
654         } else {
655                 b = append(b, tz...)
656         }
657
658         return string(b)
659 }