OSDN Git Service

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