1 package brx_IN
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 brx_IN 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 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
45 func New() locales.Translator {
46 return &brx_IN{
47 locale: "brx_IN",
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", "CNH", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59 currencyPositivePrefix: " ",
60 currencyNegativePrefix: " ",
61 monthsNarrow: []string{"", "ज", "फे", "मा", "ए", "मे", "जु", "जु", "आ", "से", "अ", "न", "दि"},
62 monthsWide: []string{"", "जानुवारी", "फेब्रुवारी", "मार्स", "एफ्रिल", "मे", "जुन", "जुलाइ", "आगस्थ", "सेबथेज्ब़र", "अखथबर", "नबेज्ब़र", "दिसेज्ब़र"},
63 daysAbbreviated: []string{"रबि", "सम", "मंगल", "बुद", "बिसथि", "सुखुर", "सुनि"},
64 daysNarrow: []string{"र", "स", "मं", "बु", "बि", "सु", "सु"},
65 daysWide: []string{"रबिबार", "समबार", "मंगलबार", "बुदबार", "बिसथिबार", "सुखुरबार", "सुनिबार"},
66 periodsAbbreviated: []string{"फुं", "बेलासे"},
67 periodsWide: []string{"फुं", "बेलासे"},
68 erasAbbreviated: []string{"ईसा.पूर्व", "सन"},
69 erasNarrow: []string{"", ""},
70 erasWide: []string{"", ""},
71 timezones: map[string]string{"ACDT": "मध्य ओस्ट्रेलिया डेलाईट टाईम", "ACST": "मध्य ओस्ट्रेलिया स्टैंडर्ड टाईम", "ACWDT": "मध्य-पश्चीम ओस्ट्रेलिया डेलाईट टाईम", "ACWST": "मध्य-पश्चीम ओस्ट्रेलिया स्टैंडर्ड टाईम", "ADT": "अटलांटीक डेलाईट टाईम", "AEDT": "पूर्वी ओस्ट्रेलिया डेलाईट टाईम", "AEST": "पूर्वी ओस्ट्रेलिया स्टैंडर्ड टाईम", "AKDT": "अलास्का डेलाईट टाईम", "AKST": "अलास्का स्टैंडर्ड टाईम", "ARST": "अर्जण्टिना समर टाईम", "ART": "अर्जनटिना स्टैंडर्ड टाईम", "AST": "अटलांटीक स्टैंडर्ड टाईम", "AWDT": "दक्षिण ओस्ट्रेलिया डेलाईट टाईम", "AWST": "दक्षिण ओस्ट्रेलिया स्टैंडर्ड टाईम", "BOT": "बोलिविया स्टैंडर्ड टाईम", "BT": "भुटान स्टैंडर्ड टाईम", "CAT": "मध्य अफ्रीका स्टैंडर्ड टाईम", "CDT": "सैंट्रल अमरिका डेलाईट टाईम", "CHADT": "चैथम डेलाईट टाईम", "CHAST": "चैथम स्टैंडर्ड टाईम", "CLST": "चीली समर टाईम", "CLT": "चीली स्टैंडर्ड टाईम", "COST": "कोलंबिया समर टाईम", "COT": "कोलंबिया स्टैंडर्ड टाईम", "CST": "सैंट्रल अमरिका स्टैंडर्ड टाईम", "ChST": "चामरो स्टैंडर्ड टाईम", "EAT": "पूर्वी अफ्रीका स्टैंडर्ड टाईम", "ECT": "एक्वाडौर स्टैंडर्ड टाईम", "EDT": "ईस्टर्न अमरिका डेलाईट टाईम", "EST": "ईस्टर्न अमरिका स्टैंडर्ड टाईम", "GFT": "फ्रान्सीसी गुयाना स्टैंडर्ड टाईम", "GMT": "ग्रीनीच स्टैंडर्ड टाईम", "GST": "गल्फ़ स्टैंडर्ड टाईम", "GYT": "गुयाना स्टैंडर्ड टाईम", "HADT": "हवाई आलटन डेलाईट टाईम", "HAST": "हवाई आलटन स्टैंडर्ड टाईम", "HAT": "न्युफाऊंडलैण्ड डेलाईट टाईम", "HECU": "क्युबा डेलाईट टाईम", "HEEG": "ग्रीनलैण्ड ईस्टर्न समर टाईम", "HENOMX": "HENOMX", "HEOG": "ग्रीनलैण्ड वेस्टर्न समर टाईम", "HEPM": "सेँ पीयॅर एवं मीकलों डेलाईट टाईम", "HEPMX": "HEPMX", "HKST": "हाँगकॉंग समर टाईम", "HKT": "हाँगकॉंग स्टैंडर्ड टाईम", "HNCU": "क्युबा स्टैंडर्ड टाईम", "HNEG": "ग्रीनलैण्ड ईस्टर्न स्टैंडर्ड टाईम", "HNNOMX": "HNNOMX", "HNOG": "ग्रीनलैण्ड वेस्टर्न स्टैंडर्ड टाईम", "HNPM": "सेँ पीयॅर एवं मीकलों स्टैंडर्ड टाईम", "HNPMX": "HNPMX", "HNT": "न्युफाऊंडलैण्ड स्टैंडर्ड टाईम", "IST": "भारतीय स्टैंडर्ड टाईम", "JDT": "जपान डेलाईट टाईम", "JST": "जपान स्टैंडर्ड टाईम", "LHDT": "लार्ड़ होव डेलाईट टाईम", "LHST": "लार्ड़ होव स्टैंडर्ड टाईम", "MDT": "अमरिका माऊन्टन डेलाईट टाईम", "MESZ": "मध्य यूरोप समर टाईम", "MEZ": "मध्य यूरोप स्टैंडर्ड टाईम", "MST": "अमरिका माऊन्टन स्टैंडर्ड टाईम", "MYT": "मलेशिया स्टैंडर्ड टाईम", "NZDT": "न्युज़ीलैण्ड डेलाईट टाईम", "NZST": "न्युज़ीलैण्ड स्टैंडर्ड टाईम", "OESZ": "ईस्टर्न यूरोप समर टाईम", "OEZ": "ईस्टर्न यूरोप स्टैंडर्ड टाईम", "PDT": "पैसीफीक डेलाईट टाईम", "PST": "पैसीफीक स्टैंडर्ड टाईम", "SAST": "दक्षिण अफ्रीका स्टैंडर्ड टाईम", "SGT": "सींगापुर स्टैंडर्ड टाईम", "SRT": "सुरीनाम स्टैंडर्ड टाईम", "TMST": "तुर्कमेनीस्तान समर टाईम", "TMT": "तुर्कमेनीस्तान स्टैंडर्ड टाईम", "UYST": "ऊरुगुए समर टाईम", "UYT": "ऊरुगुए स्टैंडर्ड टाईम", "VET": "वेनेज़ुएला स्टैंडर्ड टाईम", "WARST": "पश्चीम अर्जण्टिना समर टाईम", "WART": "पश्चीम अर्जण्टिना स्टैंडर्ड टाईम", "WAST": "पश्चीम अफ्रीका समर टाईम", "WAT": "पश्चीम अफ्रीका स्टैंडर्ड टाईम", "WESZ": "वेस्टर्न यूरोप समर टाईम", "WEZ": "वेस्टर्न यूरोप स्टैंडर्ड टाईम", "WIB": "वेस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "WIT": "ईस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "WITA": "ईंडोनीशिया स्टैंडर्ड टाईम", "∅∅∅": "ब्राज़ीलिया समर टाईम"},
72 }
73 }
74
75
76 func (brx *brx_IN) Locale() string {
77 return brx.locale
78 }
79
80
81 func (brx *brx_IN) PluralsCardinal() []locales.PluralRule {
82 return brx.pluralsCardinal
83 }
84
85
86 func (brx *brx_IN) PluralsOrdinal() []locales.PluralRule {
87 return brx.pluralsOrdinal
88 }
89
90
91 func (brx *brx_IN) PluralsRange() []locales.PluralRule {
92 return brx.pluralsRange
93 }
94
95
96 func (brx *brx_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
97
98 n := math.Abs(num)
99
100 if n == 1 {
101 return locales.PluralRuleOne
102 }
103
104 return locales.PluralRuleOther
105 }
106
107
108 func (brx *brx_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
109 return locales.PluralRuleUnknown
110 }
111
112
113 func (brx *brx_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
114 return locales.PluralRuleUnknown
115 }
116
117
118 func (brx *brx_IN) MonthAbbreviated(month time.Month) string {
119 return brx.monthsAbbreviated[month]
120 }
121
122
123 func (brx *brx_IN) MonthsAbbreviated() []string {
124 return nil
125 }
126
127
128 func (brx *brx_IN) MonthNarrow(month time.Month) string {
129 return brx.monthsNarrow[month]
130 }
131
132
133 func (brx *brx_IN) MonthsNarrow() []string {
134 return brx.monthsNarrow[1:]
135 }
136
137
138 func (brx *brx_IN) MonthWide(month time.Month) string {
139 return brx.monthsWide[month]
140 }
141
142
143 func (brx *brx_IN) MonthsWide() []string {
144 return brx.monthsWide[1:]
145 }
146
147
148 func (brx *brx_IN) WeekdayAbbreviated(weekday time.Weekday) string {
149 return brx.daysAbbreviated[weekday]
150 }
151
152
153 func (brx *brx_IN) WeekdaysAbbreviated() []string {
154 return brx.daysAbbreviated
155 }
156
157
158 func (brx *brx_IN) WeekdayNarrow(weekday time.Weekday) string {
159 return brx.daysNarrow[weekday]
160 }
161
162
163 func (brx *brx_IN) WeekdaysNarrow() []string {
164 return brx.daysNarrow
165 }
166
167
168 func (brx *brx_IN) WeekdayShort(weekday time.Weekday) string {
169 return brx.daysShort[weekday]
170 }
171
172
173 func (brx *brx_IN) WeekdaysShort() []string {
174 return brx.daysShort
175 }
176
177
178 func (brx *brx_IN) WeekdayWide(weekday time.Weekday) string {
179 return brx.daysWide[weekday]
180 }
181
182
183 func (brx *brx_IN) WeekdaysWide() []string {
184 return brx.daysWide
185 }
186
187
188 func (brx *brx_IN) Decimal() string {
189 return brx.decimal
190 }
191
192
193 func (brx *brx_IN) Group() string {
194 return brx.group
195 }
196
197
198 func (brx *brx_IN) Minus() string {
199 return brx.minus
200 }
201
202
203 func (brx *brx_IN) FmtNumber(num float64, v uint64) string {
204
205 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
207 count := 0
208 inWhole := v == 0
209 inSecondary := false
210 groupThreshold := 3
211
212 b := make([]byte, 0, l)
213
214 for i := len(s) - 1; i >= 0; i-- {
215
216 if s[i] == '.' {
217 b = append(b, brx.decimal[0])
218 inWhole = true
219 continue
220 }
221
222 if inWhole {
223
224 if count == groupThreshold {
225 b = append(b, brx.group[0])
226 count = 1
227
228 if !inSecondary {
229 inSecondary = true
230 groupThreshold = 2
231 }
232 } else {
233 count++
234 }
235 }
236
237 b = append(b, s[i])
238 }
239
240 if num < 0 {
241 b = append(b, brx.minus[0])
242 }
243
244
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
253
254 func (brx *brx_IN) FmtPercent(num float64, v uint64) string {
255 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
256 l := len(s) + 3
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, brx.decimal[0])
263 continue
264 }
265
266 b = append(b, s[i])
267 }
268
269 if num < 0 {
270 b = append(b, brx.minus[0])
271 }
272
273
274 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
275 b[i], b[j] = b[j], b[i]
276 }
277
278 b = append(b, brx.percent...)
279
280 return string(b)
281 }
282
283
284 func (brx *brx_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
285
286 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
287 symbol := brx.currencies[currency]
288 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
289 count := 0
290 inWhole := v == 0
291 inSecondary := false
292 groupThreshold := 3
293
294 b := make([]byte, 0, l)
295
296 for i := len(s) - 1; i >= 0; i-- {
297
298 if s[i] == '.' {
299 b = append(b, brx.decimal[0])
300 inWhole = true
301 continue
302 }
303
304 if inWhole {
305
306 if count == groupThreshold {
307 b = append(b, brx.group[0])
308 count = 1
309
310 if !inSecondary {
311 inSecondary = true
312 groupThreshold = 2
313 }
314 } else {
315 count++
316 }
317 }
318
319 b = append(b, s[i])
320 }
321
322 for j := len(symbol) - 1; j >= 0; j-- {
323 b = append(b, symbol[j])
324 }
325
326 for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- {
327 b = append(b, brx.currencyPositivePrefix[j])
328 }
329
330 if num < 0 {
331 b = append(b, brx.minus[0])
332 }
333
334
335 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
336 b[i], b[j] = b[j], b[i]
337 }
338
339 if int(v) < 2 {
340
341 if v == 0 {
342 b = append(b, brx.decimal...)
343 }
344
345 for i := 0; i < 2-int(v); i++ {
346 b = append(b, '0')
347 }
348 }
349
350 return string(b)
351 }
352
353
354
355 func (brx *brx_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
356
357 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
358 symbol := brx.currencies[currency]
359 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
360 count := 0
361 inWhole := v == 0
362 inSecondary := false
363 groupThreshold := 3
364
365 b := make([]byte, 0, l)
366
367 for i := len(s) - 1; i >= 0; i-- {
368
369 if s[i] == '.' {
370 b = append(b, brx.decimal[0])
371 inWhole = true
372 continue
373 }
374
375 if inWhole {
376
377 if count == groupThreshold {
378 b = append(b, brx.group[0])
379 count = 1
380
381 if !inSecondary {
382 inSecondary = true
383 groupThreshold = 2
384 }
385 } else {
386 count++
387 }
388 }
389
390 b = append(b, s[i])
391 }
392
393 if num < 0 {
394
395 for j := len(symbol) - 1; j >= 0; j-- {
396 b = append(b, symbol[j])
397 }
398
399 for j := len(brx.currencyNegativePrefix) - 1; j >= 0; j-- {
400 b = append(b, brx.currencyNegativePrefix[j])
401 }
402
403 b = append(b, brx.minus[0])
404
405 } else {
406
407 for j := len(symbol) - 1; j >= 0; j-- {
408 b = append(b, symbol[j])
409 }
410
411 for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- {
412 b = append(b, brx.currencyPositivePrefix[j])
413 }
414
415 }
416
417
418 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
419 b[i], b[j] = b[j], b[i]
420 }
421
422 if int(v) < 2 {
423
424 if v == 0 {
425 b = append(b, brx.decimal...)
426 }
427
428 for i := 0; i < 2-int(v); i++ {
429 b = append(b, '0')
430 }
431 }
432
433 return string(b)
434 }
435
436
437 func (brx *brx_IN) FmtDateShort(t time.Time) string {
438
439 b := make([]byte, 0, 32)
440
441 b = strconv.AppendInt(b, int64(t.Month()), 10)
442 b = append(b, []byte{0x2f}...)
443 b = strconv.AppendInt(b, int64(t.Day()), 10)
444 b = append(b, []byte{0x2f}...)
445
446 if t.Year() > 9 {
447 b = append(b, strconv.Itoa(t.Year())[2:]...)
448 } else {
449 b = append(b, strconv.Itoa(t.Year())[1:]...)
450 }
451
452 return string(b)
453 }
454
455
456 func (brx *brx_IN) FmtDateMedium(t time.Time) string {
457
458 b := make([]byte, 0, 32)
459
460 b = append(b, brx.monthsAbbreviated[t.Month()]...)
461 b = append(b, []byte{0x20}...)
462 b = strconv.AppendInt(b, int64(t.Day()), 10)
463 b = append(b, []byte{0x2c, 0x20}...)
464
465 if t.Year() > 0 {
466 b = strconv.AppendInt(b, int64(t.Year()), 10)
467 } else {
468 b = strconv.AppendInt(b, int64(-t.Year()), 10)
469 }
470
471 return string(b)
472 }
473
474
475 func (brx *brx_IN) FmtDateLong(t time.Time) string {
476
477 b := make([]byte, 0, 32)
478
479 b = append(b, brx.monthsWide[t.Month()]...)
480 b = append(b, []byte{0x20}...)
481 b = strconv.AppendInt(b, int64(t.Day()), 10)
482 b = append(b, []byte{0x2c, 0x20}...)
483
484 if t.Year() > 0 {
485 b = strconv.AppendInt(b, int64(t.Year()), 10)
486 } else {
487 b = strconv.AppendInt(b, int64(-t.Year()), 10)
488 }
489
490 return string(b)
491 }
492
493
494 func (brx *brx_IN) FmtDateFull(t time.Time) string {
495
496 b := make([]byte, 0, 32)
497
498 b = append(b, brx.daysWide[t.Weekday()]...)
499 b = append(b, []byte{0x2c, 0x20}...)
500 b = append(b, brx.monthsWide[t.Month()]...)
501 b = append(b, []byte{0x20}...)
502 b = strconv.AppendInt(b, int64(t.Day()), 10)
503 b = append(b, []byte{0x2c, 0x20}...)
504
505 if t.Year() > 0 {
506 b = strconv.AppendInt(b, int64(t.Year()), 10)
507 } else {
508 b = strconv.AppendInt(b, int64(-t.Year()), 10)
509 }
510
511 return string(b)
512 }
513
514
515 func (brx *brx_IN) FmtTimeShort(t time.Time) string {
516
517 b := make([]byte, 0, 32)
518
519 h := t.Hour()
520
521 if h > 12 {
522 h -= 12
523 }
524
525 b = strconv.AppendInt(b, int64(h), 10)
526 b = append(b, brx.timeSeparator...)
527
528 if t.Minute() < 10 {
529 b = append(b, '0')
530 }
531
532 b = strconv.AppendInt(b, int64(t.Minute()), 10)
533 b = append(b, []byte{0x20}...)
534
535 if t.Hour() < 12 {
536 b = append(b, brx.periodsAbbreviated[0]...)
537 } else {
538 b = append(b, brx.periodsAbbreviated[1]...)
539 }
540
541 return string(b)
542 }
543
544
545 func (brx *brx_IN) FmtTimeMedium(t time.Time) string {
546
547 b := make([]byte, 0, 32)
548
549 h := t.Hour()
550
551 if h > 12 {
552 h -= 12
553 }
554
555 b = strconv.AppendInt(b, int64(h), 10)
556 b = append(b, brx.timeSeparator...)
557
558 if t.Minute() < 10 {
559 b = append(b, '0')
560 }
561
562 b = strconv.AppendInt(b, int64(t.Minute()), 10)
563 b = append(b, brx.timeSeparator...)
564
565 if t.Second() < 10 {
566 b = append(b, '0')
567 }
568
569 b = strconv.AppendInt(b, int64(t.Second()), 10)
570 b = append(b, []byte{0x20}...)
571
572 if t.Hour() < 12 {
573 b = append(b, brx.periodsAbbreviated[0]...)
574 } else {
575 b = append(b, brx.periodsAbbreviated[1]...)
576 }
577
578 return string(b)
579 }
580
581
582 func (brx *brx_IN) FmtTimeLong(t time.Time) string {
583
584 b := make([]byte, 0, 32)
585
586 h := t.Hour()
587
588 if h > 12 {
589 h -= 12
590 }
591
592 b = strconv.AppendInt(b, int64(h), 10)
593 b = append(b, brx.timeSeparator...)
594
595 if t.Minute() < 10 {
596 b = append(b, '0')
597 }
598
599 b = strconv.AppendInt(b, int64(t.Minute()), 10)
600 b = append(b, brx.timeSeparator...)
601
602 if t.Second() < 10 {
603 b = append(b, '0')
604 }
605
606 b = strconv.AppendInt(b, int64(t.Second()), 10)
607 b = append(b, []byte{0x20}...)
608
609 if t.Hour() < 12 {
610 b = append(b, brx.periodsAbbreviated[0]...)
611 } else {
612 b = append(b, brx.periodsAbbreviated[1]...)
613 }
614
615 b = append(b, []byte{0x20}...)
616
617 tz, _ := t.Zone()
618 b = append(b, tz...)
619
620 return string(b)
621 }
622
623
624 func (brx *brx_IN) FmtTimeFull(t time.Time) string {
625
626 b := make([]byte, 0, 32)
627
628 h := t.Hour()
629
630 if h > 12 {
631 h -= 12
632 }
633
634 b = strconv.AppendInt(b, int64(h), 10)
635 b = append(b, brx.timeSeparator...)
636
637 if t.Minute() < 10 {
638 b = append(b, '0')
639 }
640
641 b = strconv.AppendInt(b, int64(t.Minute()), 10)
642 b = append(b, brx.timeSeparator...)
643
644 if t.Second() < 10 {
645 b = append(b, '0')
646 }
647
648 b = strconv.AppendInt(b, int64(t.Second()), 10)
649 b = append(b, []byte{0x20}...)
650
651 if t.Hour() < 12 {
652 b = append(b, brx.periodsAbbreviated[0]...)
653 } else {
654 b = append(b, brx.periodsAbbreviated[1]...)
655 }
656
657 b = append(b, []byte{0x20}...)
658
659 tz, _ := t.Zone()
660
661 if btz, ok := brx.timezones[tz]; ok {
662 b = append(b, btz...)
663 } else {
664 b = append(b, tz...)
665 }
666
667 return string(b)
668 }
669
View as plain text