1 package my
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 my 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 &my{
47 locale: "my",
48 pluralsCardinal: []locales.PluralRule{6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{6},
51 decimal: ".",
52 group: ",",
53 minus: "-",
54 percent: "%",
55 perMille: "‰",
56 timeSeparator: ":",
57 inifinity: "∞",
58 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "NAf", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "Afl", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "G", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "K", "MNT", "MOP", "MRO", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "B/.", "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", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TT$", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "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 monthsAbbreviated: []string{"", "ဇန်", "ဖေ", "မတ်", "ဧ", "မေ", "ဇွန်", "ဇူ", "ဩ", "စက်", "အောက်", "နို", "ဒီ"},
62 monthsNarrow: []string{"", "ဇ", "ဖ", "မ", "ဧ", "မ", "ဇ", "ဇ", "ဩ", "စ", "အ", "န", "ဒ"},
63 monthsWide: []string{"", "ဇန်နဝါရီ", "ဖေဖော်ဝါရီ", "မတ်", "ဧပြီ", "မေ", "ဇွန်", "ဇူလိုင်", "ဩဂုတ်", "စက်တင်ဘာ", "အောက်တိုဘာ", "နိုဝင်ဘာ", "ဒီဇင်ဘာ"},
64 daysAbbreviated: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"},
65 daysNarrow: []string{"တ", "တ", "အ", "ဗ", "က", "သ", "စ"},
66 daysShort: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"},
67 daysWide: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"},
68 periodsAbbreviated: []string{"နံနက်", "ညနေ"},
69 periodsNarrow: []string{"နံနက်", "ညနေ"},
70 periodsWide: []string{"နံနက်", "ညနေ"},
71 erasAbbreviated: []string{"ဘီစီ", "အဒေီ"},
72 erasNarrow: []string{"", ""},
73 erasWide: []string{"ခရစ်တော် မပေါ်မီနှစ်", "ခရစ်နှစ်"},
74 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": "အနောက်တောင် မက္ကစီကို နွေရာသီ စံတော်ချိန်", "HEOG": "အနောက် ဂရင်းလန် နွေရာသီ စံတော်ချိန်", "HEPM": "စိန့်ပီအဲနှင့် မီခွီလွန် နွေရာသီ စံတော်ချိန်", "HEPMX": "မက္ကစီကန် ပစိဖိတ် နွေရာသီ စံတော်ချိန်", "HKST": "ဟောင်ကောင် နွေရာသီ အချိန်", "HKT": "ဟောင်ကောင် စံတော်ချိန်", "HNCU": "ကျူးဘား စံတော်ချိန်", "HNEG": "အရှေ့ဂရင်းလန်း စံတော်ချိန်", "HNNOMX": "အနောက်တောင် မက္ကဆီကို စံတော်ချိန်", "HNOG": "အနောက် ဂရင်းလန်း စံတော်ချိန်", "HNPM": "စိန့်ပီအဲနှင့်မီခွီလွန်စံတော်ချိန်", "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": "အလယ်ပိုင်း အင်ဒိုနီးရှား အချိန်", "∅∅∅": "ဘရာဇီး နွေရာသီ အချိန်"},
75 }
76 }
77
78
79 func (my *my) Locale() string {
80 return my.locale
81 }
82
83
84 func (my *my) PluralsCardinal() []locales.PluralRule {
85 return my.pluralsCardinal
86 }
87
88
89 func (my *my) PluralsOrdinal() []locales.PluralRule {
90 return my.pluralsOrdinal
91 }
92
93
94 func (my *my) PluralsRange() []locales.PluralRule {
95 return my.pluralsRange
96 }
97
98
99 func (my *my) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleOther
101 }
102
103
104 func (my *my) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105 return locales.PluralRuleOther
106 }
107
108
109 func (my *my) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
110 return locales.PluralRuleOther
111 }
112
113
114 func (my *my) MonthAbbreviated(month time.Month) string {
115 return my.monthsAbbreviated[month]
116 }
117
118
119 func (my *my) MonthsAbbreviated() []string {
120 return my.monthsAbbreviated[1:]
121 }
122
123
124 func (my *my) MonthNarrow(month time.Month) string {
125 return my.monthsNarrow[month]
126 }
127
128
129 func (my *my) MonthsNarrow() []string {
130 return my.monthsNarrow[1:]
131 }
132
133
134 func (my *my) MonthWide(month time.Month) string {
135 return my.monthsWide[month]
136 }
137
138
139 func (my *my) MonthsWide() []string {
140 return my.monthsWide[1:]
141 }
142
143
144 func (my *my) WeekdayAbbreviated(weekday time.Weekday) string {
145 return my.daysAbbreviated[weekday]
146 }
147
148
149 func (my *my) WeekdaysAbbreviated() []string {
150 return my.daysAbbreviated
151 }
152
153
154 func (my *my) WeekdayNarrow(weekday time.Weekday) string {
155 return my.daysNarrow[weekday]
156 }
157
158
159 func (my *my) WeekdaysNarrow() []string {
160 return my.daysNarrow
161 }
162
163
164 func (my *my) WeekdayShort(weekday time.Weekday) string {
165 return my.daysShort[weekday]
166 }
167
168
169 func (my *my) WeekdaysShort() []string {
170 return my.daysShort
171 }
172
173
174 func (my *my) WeekdayWide(weekday time.Weekday) string {
175 return my.daysWide[weekday]
176 }
177
178
179 func (my *my) WeekdaysWide() []string {
180 return my.daysWide
181 }
182
183
184 func (my *my) Decimal() string {
185 return my.decimal
186 }
187
188
189 func (my *my) Group() string {
190 return my.group
191 }
192
193
194 func (my *my) Minus() string {
195 return my.minus
196 }
197
198
199 func (my *my) FmtNumber(num float64, v uint64) string {
200
201 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
203 count := 0
204 inWhole := v == 0
205 b := make([]byte, 0, l)
206
207 for i := len(s) - 1; i >= 0; i-- {
208
209 if s[i] == '.' {
210 b = append(b, my.decimal[0])
211 inWhole = true
212 continue
213 }
214
215 if inWhole {
216 if count == 3 {
217 b = append(b, my.group[0])
218 count = 1
219 } else {
220 count++
221 }
222 }
223
224 b = append(b, s[i])
225 }
226
227 if num < 0 {
228 b = append(b, my.minus[0])
229 }
230
231
232 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
233 b[i], b[j] = b[j], b[i]
234 }
235
236 return string(b)
237 }
238
239
240
241 func (my *my) FmtPercent(num float64, v uint64) string {
242 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
243 l := len(s) + 3
244 b := make([]byte, 0, l)
245
246 for i := len(s) - 1; i >= 0; i-- {
247
248 if s[i] == '.' {
249 b = append(b, my.decimal[0])
250 continue
251 }
252
253 b = append(b, s[i])
254 }
255
256 if num < 0 {
257 b = append(b, my.minus[0])
258 }
259
260
261 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
262 b[i], b[j] = b[j], b[i]
263 }
264
265 b = append(b, my.percent...)
266
267 return string(b)
268 }
269
270
271 func (my *my) FmtCurrency(num float64, v uint64, currency currency.Type) string {
272
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := my.currencies[currency]
275 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
276 count := 0
277 inWhole := v == 0
278 b := make([]byte, 0, l)
279
280 for i := len(s) - 1; i >= 0; i-- {
281
282 if s[i] == '.' {
283 b = append(b, my.decimal[0])
284 inWhole = true
285 continue
286 }
287
288 if inWhole {
289 if count == 3 {
290 b = append(b, my.group[0])
291 count = 1
292 } else {
293 count++
294 }
295 }
296
297 b = append(b, s[i])
298 }
299
300 for j := len(symbol) - 1; j >= 0; j-- {
301 b = append(b, symbol[j])
302 }
303
304 for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- {
305 b = append(b, my.currencyPositivePrefix[j])
306 }
307
308 if num < 0 {
309 b = append(b, my.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, my.decimal...)
321 }
322
323 for i := 0; i < 2-int(v); i++ {
324 b = append(b, '0')
325 }
326 }
327
328 return string(b)
329 }
330
331
332
333 func (my *my) FmtAccounting(num float64, v uint64, currency currency.Type) string {
334
335 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
336 symbol := my.currencies[currency]
337 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
338 count := 0
339 inWhole := v == 0
340 b := make([]byte, 0, l)
341
342 for i := len(s) - 1; i >= 0; i-- {
343
344 if s[i] == '.' {
345 b = append(b, my.decimal[0])
346 inWhole = true
347 continue
348 }
349
350 if inWhole {
351 if count == 3 {
352 b = append(b, my.group[0])
353 count = 1
354 } else {
355 count++
356 }
357 }
358
359 b = append(b, s[i])
360 }
361
362 if num < 0 {
363
364 for j := len(symbol) - 1; j >= 0; j-- {
365 b = append(b, symbol[j])
366 }
367
368 for j := len(my.currencyNegativePrefix) - 1; j >= 0; j-- {
369 b = append(b, my.currencyNegativePrefix[j])
370 }
371
372 b = append(b, my.minus[0])
373
374 } else {
375
376 for j := len(symbol) - 1; j >= 0; j-- {
377 b = append(b, symbol[j])
378 }
379
380 for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- {
381 b = append(b, my.currencyPositivePrefix[j])
382 }
383
384 }
385
386
387 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
388 b[i], b[j] = b[j], b[i]
389 }
390
391 if int(v) < 2 {
392
393 if v == 0 {
394 b = append(b, my.decimal...)
395 }
396
397 for i := 0; i < 2-int(v); i++ {
398 b = append(b, '0')
399 }
400 }
401
402 return string(b)
403 }
404
405
406 func (my *my) FmtDateShort(t time.Time) string {
407
408 b := make([]byte, 0, 32)
409
410 if t.Day() < 10 {
411 b = append(b, '0')
412 }
413
414 b = strconv.AppendInt(b, int64(t.Day()), 10)
415 b = append(b, []byte{0x2d}...)
416
417 if t.Month() < 10 {
418 b = append(b, '0')
419 }
420
421 b = strconv.AppendInt(b, int64(t.Month()), 10)
422
423 b = append(b, []byte{0x2d}...)
424
425 if t.Year() > 9 {
426 b = append(b, strconv.Itoa(t.Year())[2:]...)
427 } else {
428 b = append(b, strconv.Itoa(t.Year())[1:]...)
429 }
430
431 return string(b)
432 }
433
434
435 func (my *my) FmtDateMedium(t time.Time) string {
436
437 b := make([]byte, 0, 32)
438
439 if t.Year() > 0 {
440 b = strconv.AppendInt(b, int64(t.Year()), 10)
441 } else {
442 b = strconv.AppendInt(b, int64(-t.Year()), 10)
443 }
444
445 b = append(b, []byte{0xe1, 0x81, 0x8a, 0x20}...)
446 b = append(b, my.monthsAbbreviated[t.Month()]...)
447 b = append(b, []byte{0x20}...)
448 b = strconv.AppendInt(b, int64(t.Day()), 10)
449
450 return string(b)
451 }
452
453
454 func (my *my) FmtDateLong(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 if t.Year() > 0 {
459 b = strconv.AppendInt(b, int64(t.Year()), 10)
460 } else {
461 b = strconv.AppendInt(b, int64(-t.Year()), 10)
462 }
463
464 b = append(b, []byte{0xe1, 0x81, 0x8a, 0x20}...)
465 b = strconv.AppendInt(b, int64(t.Day()), 10)
466 b = append(b, []byte{0x20}...)
467 b = append(b, my.monthsWide[t.Month()]...)
468
469 return string(b)
470 }
471
472
473 func (my *my) FmtDateFull(t time.Time) string {
474
475 b := make([]byte, 0, 32)
476
477 if t.Year() > 0 {
478 b = strconv.AppendInt(b, int64(t.Year()), 10)
479 } else {
480 b = strconv.AppendInt(b, int64(-t.Year()), 10)
481 }
482
483 b = append(b, []byte{0xe1, 0x81, 0x8a, 0x20}...)
484 b = append(b, my.monthsWide[t.Month()]...)
485 b = append(b, []byte{0x20}...)
486 b = strconv.AppendInt(b, int64(t.Day()), 10)
487 b = append(b, []byte{0xe1, 0x81, 0x8a, 0x20}...)
488 b = append(b, my.daysWide[t.Weekday()]...)
489
490 return string(b)
491 }
492
493
494 func (my *my) FmtTimeShort(t time.Time) string {
495
496 b := make([]byte, 0, 32)
497
498 b = append(b, []byte{0x42, 0x20}...)
499 b = strconv.AppendInt(b, int64(t.Hour()), 10)
500 b = append(b, my.timeSeparator...)
501
502 if t.Minute() < 10 {
503 b = append(b, '0')
504 }
505
506 b = strconv.AppendInt(b, int64(t.Minute()), 10)
507
508 return string(b)
509 }
510
511
512 func (my *my) FmtTimeMedium(t time.Time) string {
513
514 b := make([]byte, 0, 32)
515
516 b = append(b, []byte{0x42, 0x20}...)
517
518 if t.Hour() < 10 {
519 b = append(b, '0')
520 }
521
522 b = strconv.AppendInt(b, int64(t.Hour()), 10)
523 b = append(b, my.timeSeparator...)
524
525 if t.Minute() < 10 {
526 b = append(b, '0')
527 }
528
529 b = strconv.AppendInt(b, int64(t.Minute()), 10)
530 b = append(b, my.timeSeparator...)
531
532 if t.Second() < 10 {
533 b = append(b, '0')
534 }
535
536 b = strconv.AppendInt(b, int64(t.Second()), 10)
537
538 return string(b)
539 }
540
541
542 func (my *my) FmtTimeLong(t time.Time) string {
543
544 b := make([]byte, 0, 32)
545
546 tz, _ := t.Zone()
547 b = append(b, tz...)
548
549 b = append(b, []byte{0x20}...)
550
551 if t.Hour() < 10 {
552 b = append(b, '0')
553 }
554
555 b = strconv.AppendInt(b, int64(t.Hour()), 10)
556 b = append(b, my.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, my.timeSeparator...)
564
565 if t.Second() < 10 {
566 b = append(b, '0')
567 }
568
569 b = strconv.AppendInt(b, int64(t.Second()), 10)
570
571 return string(b)
572 }
573
574
575 func (my *my) FmtTimeFull(t time.Time) string {
576
577 b := make([]byte, 0, 32)
578
579 tz, _ := t.Zone()
580
581 if btz, ok := my.timezones[tz]; ok {
582 b = append(b, btz...)
583 } else {
584 b = append(b, tz...)
585 }
586
587 b = append(b, []byte{0x20}...)
588
589 if t.Hour() < 10 {
590 b = append(b, '0')
591 }
592
593 b = strconv.AppendInt(b, int64(t.Hour()), 10)
594 b = append(b, my.timeSeparator...)
595
596 if t.Minute() < 10 {
597 b = append(b, '0')
598 }
599
600 b = strconv.AppendInt(b, int64(t.Minute()), 10)
601 b = append(b, my.timeSeparator...)
602
603 if t.Second() < 10 {
604 b = append(b, '0')
605 }
606
607 b = strconv.AppendInt(b, int64(t.Second()), 10)
608
609 return string(b)
610 }
611
View as plain text