1 package ee
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 ee 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 currencyNegativePrefix string
26 currencyNegativeSuffix 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 &ee{
47 locale: "ee",
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", "AU$", "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", "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", "GH₵", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "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", "MMK", "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", "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", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "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 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "dzv", "dzd", "ted", "afɔ", "dam", "mas", "sia", "dea", "any", "kel", "ade", "dzm"},
62 monthsNarrow: []string{"", "d", "d", "t", "a", "d", "m", "s", "d", "a", "k", "a", "d"},
63 monthsWide: []string{"", "dzove", "dzodze", "tedoxe", "afɔfĩe", "dama", "masa", "siamlɔm", "deasiamime", "anyɔnyɔ", "kele", "adeɛmekpɔxe", "dzome"},
64 daysAbbreviated: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"},
65 daysNarrow: []string{"k", "d", "b", "k", "y", "f", "m"},
66 daysShort: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"},
67 daysWide: []string{"kɔsiɖa", "dzoɖa", "blaɖa", "kuɖa", "yawoɖa", "fiɖa", "memleɖa"},
68 periodsAbbreviated: []string{"ŋdi", "ɣetrɔ"},
69 periodsNarrow: []string{"ŋ", "ɣ"},
70 periodsWide: []string{"ŋdi", "ɣetrɔ"},
71 erasAbbreviated: []string{"HYV", "Yŋ"},
72 erasNarrow: []string{"hY", "Yŋ"},
73 erasWide: []string{"", ""},
74 timezones: map[string]string{"ACDT": "Australian Central dzomeli gaƒoƒo me", "ACST": "Australian Central nutome gaƒoƒo me", "ACWDT": "Australian Central Western kele gaƒoƒo me", "ACWST": "Australian Central Western nutome gaƒoƒo me", "ADT": "Atlantic kele gaƒoƒome", "AEDT": "Australian Eastern kele gaƒoƒo me", "AEST": "Australian Eastern nutome gaƒoƒo me", "AKDT": "Alaska kele gaƒoƒo me", "AKST": "Alaska nutome gaƒoƒo me", "ARST": "Argentina dzomeŋɔli gaƒoƒo me", "ART": "Argentina nutome gaƒoƒo me", "AST": "Atlantic nutome gaƒoƒome", "AWDT": "Australian Western kele gaƒoƒo me", "AWST": "Australian Western nutome gaƒoƒo me", "BOT": "Bolivia gaƒoƒo me", "BT": "Bhutan gaƒoƒo me", "CAT": "Central Africa gaƒoƒo me", "CDT": "Titina America kele gaƒoƒo me", "CHADT": "Chatham kele gaƒoƒo me", "CHAST": "Chatham nutome gaƒoƒo me", "CLST": "Chile dzomeŋɔli gaƒoƒo me", "CLT": "Chile nutome gaƒoƒo me", "COST": "Colombia dzomeŋɔli gaƒoƒo me", "COT": "Colombia nutome gaƒoƒo me", "CST": "Titina America nutome gaƒoƒo me", "ChST": "Chamorro gaƒoƒo me", "EAT": "East Africa gaƒoƒo me", "ECT": "Ecuador gaƒoƒo me", "EDT": "Eastern America kele gaƒoƒo me", "EST": "Eastern America nutome gaƒoƒo me", "GFT": "French Guiana gaƒoƒo me", "GMT": "Greenwich gaƒoƒo me", "GST": "Gulf nutome gaƒoƒo me", "GYT": "Guyana gaƒoƒo me", "HADT": "Hawaii-Aleutia kele gaƒoƒo me", "HAST": "Hawaii-Aleutia nutome gaƒoƒo me", "HAT": "Newfoundland kele gaƒoƒome", "HECU": "Cuba kele gaƒoƒome", "HEEG": "East Greenland dzomeŋɔli gaƒoƒo me", "HENOMX": "Northwest Mexico kele gaƒoƒo me", "HEOG": "West Greenland kele gaƒoƒo me", "HEPM": "St. Pierre & Miquelon kele gaƒoƒome", "HEPMX": "Mexican Pacific kele gaƒoƒome", "HKST": "Hong Kong dzomeŋɔli gaƒoƒo me", "HKT": "Hong Kong nutome gaƒoƒo me", "HNCU": "Cuba nutome gaƒoƒome", "HNEG": "East Greenland nutome gaƒoƒo me", "HNNOMX": "Northwest Mexico nutome gaƒoƒo me", "HNOG": "West Greenland nutome gaƒoƒo me", "HNPM": "St. Pierre & Miquelon nutome gaƒoƒome", "HNPMX": "Mexican Pacific nutome gaƒoƒo me", "HNT": "Newfoundland nutome gaƒoƒome", "IST": "India gaƒoƒo me", "JDT": "Japan dzomeŋɔli gaƒoƒo me", "JST": "Japan nutome gaƒoƒo me", "LHDT": "Lord Howe kele gaƒoƒo me", "LHST": "Lord Howe nutome gaƒoƒo me", "MDT": "Mountain kele gaƒoƒo me", "MESZ": "Central Europe dzomeŋɔli gaƒoƒo me", "MEZ": "Central Europe nutome gaƒoƒo me", "MST": "Mountain nutome gaƒoƒo me", "MYT": "Malaysia gaƒoƒo me", "NZDT": "New Zealand kele gaƒoƒo me", "NZST": "New Zealand nutome gaƒoƒo me", "OESZ": "Ɣedzeƒe Europe ŋkekeme gaƒoƒome", "OEZ": "Ɣedzeƒe Europe gaƒoƒoɖoanyime", "PDT": "Pacific kele gaƒoƒo me", "PST": "Pacific nutome gaƒoƒo me", "SAST": "South Africa nutome gaƒoƒo me", "SGT": "Singapore nutome gaƒoƒo me", "SRT": "Suriname gaƒoƒome", "TMST": "Turkmenistan dzomeŋɔli gaƒoƒo me", "TMT": "Turkmenistan nutome gaƒoƒo me", "UYST": "Uruguay dzomeŋɔli gaƒoƒo me", "UYT": "Uruguay nutome gaƒoƒo me", "VET": "Venezuela gaƒoƒo me", "WARST": "Ɣetoɖoƒe Argentina dzomeŋɔli gaƒoƒo me", "WART": "Ɣetoɖoƒe Argentina nutome gaƒoƒo me", "WAST": "West Africa dzomeŋɔli gaƒoƒo me", "WAT": "West Africa nutome gaƒoƒo me", "WESZ": "Western Europe dzomeŋɔli gaƒoƒo me", "WEZ": "Western Europe nutome gaƒoƒo me", "WIB": "Western Indonesia gaƒoƒo me", "WIT": "Eastern Indonesia gaƒoƒo me", "WITA": "Central Indonesia gaƒoƒo me", "∅∅∅": "Peru dzomeŋɔli gaƒoƒome"},
75 }
76 }
77
78
79 func (ee *ee) Locale() string {
80 return ee.locale
81 }
82
83
84 func (ee *ee) PluralsCardinal() []locales.PluralRule {
85 return ee.pluralsCardinal
86 }
87
88
89 func (ee *ee) PluralsOrdinal() []locales.PluralRule {
90 return ee.pluralsOrdinal
91 }
92
93
94 func (ee *ee) PluralsRange() []locales.PluralRule {
95 return ee.pluralsRange
96 }
97
98
99 func (ee *ee) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101 n := math.Abs(num)
102
103 if n == 1 {
104 return locales.PluralRuleOne
105 }
106
107 return locales.PluralRuleOther
108 }
109
110
111 func (ee *ee) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
112 return locales.PluralRuleUnknown
113 }
114
115
116 func (ee *ee) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
117 return locales.PluralRuleUnknown
118 }
119
120
121 func (ee *ee) MonthAbbreviated(month time.Month) string {
122 return ee.monthsAbbreviated[month]
123 }
124
125
126 func (ee *ee) MonthsAbbreviated() []string {
127 return ee.monthsAbbreviated[1:]
128 }
129
130
131 func (ee *ee) MonthNarrow(month time.Month) string {
132 return ee.monthsNarrow[month]
133 }
134
135
136 func (ee *ee) MonthsNarrow() []string {
137 return ee.monthsNarrow[1:]
138 }
139
140
141 func (ee *ee) MonthWide(month time.Month) string {
142 return ee.monthsWide[month]
143 }
144
145
146 func (ee *ee) MonthsWide() []string {
147 return ee.monthsWide[1:]
148 }
149
150
151 func (ee *ee) WeekdayAbbreviated(weekday time.Weekday) string {
152 return ee.daysAbbreviated[weekday]
153 }
154
155
156 func (ee *ee) WeekdaysAbbreviated() []string {
157 return ee.daysAbbreviated
158 }
159
160
161 func (ee *ee) WeekdayNarrow(weekday time.Weekday) string {
162 return ee.daysNarrow[weekday]
163 }
164
165
166 func (ee *ee) WeekdaysNarrow() []string {
167 return ee.daysNarrow
168 }
169
170
171 func (ee *ee) WeekdayShort(weekday time.Weekday) string {
172 return ee.daysShort[weekday]
173 }
174
175
176 func (ee *ee) WeekdaysShort() []string {
177 return ee.daysShort
178 }
179
180
181 func (ee *ee) WeekdayWide(weekday time.Weekday) string {
182 return ee.daysWide[weekday]
183 }
184
185
186 func (ee *ee) WeekdaysWide() []string {
187 return ee.daysWide
188 }
189
190
191 func (ee *ee) Decimal() string {
192 return ee.decimal
193 }
194
195
196 func (ee *ee) Group() string {
197 return ee.group
198 }
199
200
201 func (ee *ee) Minus() string {
202 return ee.minus
203 }
204
205
206 func (ee *ee) FmtNumber(num float64, v uint64) string {
207
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
210 count := 0
211 inWhole := v == 0
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, ee.decimal[0])
218 inWhole = true
219 continue
220 }
221
222 if inWhole {
223 if count == 3 {
224 b = append(b, ee.group[0])
225 count = 1
226 } else {
227 count++
228 }
229 }
230
231 b = append(b, s[i])
232 }
233
234 if num < 0 {
235 b = append(b, ee.minus[0])
236 }
237
238
239 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240 b[i], b[j] = b[j], b[i]
241 }
242
243 return string(b)
244 }
245
246
247
248 func (ee *ee) FmtPercent(num float64, v uint64) string {
249 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250 l := len(s) + 3
251 b := make([]byte, 0, l)
252
253 for i := len(s) - 1; i >= 0; i-- {
254
255 if s[i] == '.' {
256 b = append(b, ee.decimal[0])
257 continue
258 }
259
260 b = append(b, s[i])
261 }
262
263 if num < 0 {
264 b = append(b, ee.minus[0])
265 }
266
267
268 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
269 b[i], b[j] = b[j], b[i]
270 }
271
272 b = append(b, ee.percent...)
273
274 return string(b)
275 }
276
277
278 func (ee *ee) FmtCurrency(num float64, v uint64, currency currency.Type) string {
279
280 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
281 symbol := ee.currencies[currency]
282 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
283 count := 0
284 inWhole := v == 0
285 b := make([]byte, 0, l)
286
287 for i := len(s) - 1; i >= 0; i-- {
288
289 if s[i] == '.' {
290 b = append(b, ee.decimal[0])
291 inWhole = true
292 continue
293 }
294
295 if inWhole {
296 if count == 3 {
297 b = append(b, ee.group[0])
298 count = 1
299 } else {
300 count++
301 }
302 }
303
304 b = append(b, s[i])
305 }
306
307 for j := len(symbol) - 1; j >= 0; j-- {
308 b = append(b, symbol[j])
309 }
310
311 if num < 0 {
312 b = append(b, ee.minus[0])
313 }
314
315
316 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
317 b[i], b[j] = b[j], b[i]
318 }
319
320 if int(v) < 2 {
321
322 if v == 0 {
323 b = append(b, ee.decimal...)
324 }
325
326 for i := 0; i < 2-int(v); i++ {
327 b = append(b, '0')
328 }
329 }
330
331 return string(b)
332 }
333
334
335
336 func (ee *ee) FmtAccounting(num float64, v uint64, currency currency.Type) string {
337
338 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339 symbol := ee.currencies[currency]
340 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
341 count := 0
342 inWhole := v == 0
343 b := make([]byte, 0, l)
344
345 for i := len(s) - 1; i >= 0; i-- {
346
347 if s[i] == '.' {
348 b = append(b, ee.decimal[0])
349 inWhole = true
350 continue
351 }
352
353 if inWhole {
354 if count == 3 {
355 b = append(b, ee.group[0])
356 count = 1
357 } else {
358 count++
359 }
360 }
361
362 b = append(b, s[i])
363 }
364
365 if num < 0 {
366
367 for j := len(symbol) - 1; j >= 0; j-- {
368 b = append(b, symbol[j])
369 }
370
371 b = append(b, ee.currencyNegativePrefix[0])
372
373 } else {
374
375 for j := len(symbol) - 1; j >= 0; j-- {
376 b = append(b, symbol[j])
377 }
378
379 }
380
381
382 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
383 b[i], b[j] = b[j], b[i]
384 }
385
386 if int(v) < 2 {
387
388 if v == 0 {
389 b = append(b, ee.decimal...)
390 }
391
392 for i := 0; i < 2-int(v); i++ {
393 b = append(b, '0')
394 }
395 }
396
397 if num < 0 {
398 b = append(b, ee.currencyNegativeSuffix...)
399 }
400
401 return string(b)
402 }
403
404
405 func (ee *ee) FmtDateShort(t time.Time) string {
406
407 b := make([]byte, 0, 32)
408
409 b = strconv.AppendInt(b, int64(t.Month()), 10)
410 b = append(b, []byte{0x2f}...)
411 b = strconv.AppendInt(b, int64(t.Day()), 10)
412 b = append(b, []byte{0x2f}...)
413
414 if t.Year() > 9 {
415 b = append(b, strconv.Itoa(t.Year())[2:]...)
416 } else {
417 b = append(b, strconv.Itoa(t.Year())[1:]...)
418 }
419
420 return string(b)
421 }
422
423
424 func (ee *ee) FmtDateMedium(t time.Time) string {
425
426 b := make([]byte, 0, 32)
427
428 b = append(b, ee.monthsAbbreviated[t.Month()]...)
429 b = append(b, []byte{0x20}...)
430 b = strconv.AppendInt(b, int64(t.Day()), 10)
431 b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...)
432 b = append(b, []byte{0x2c, 0x20}...)
433
434 if t.Year() > 0 {
435 b = strconv.AppendInt(b, int64(t.Year()), 10)
436 } else {
437 b = strconv.AppendInt(b, int64(-t.Year()), 10)
438 }
439
440 return string(b)
441 }
442
443
444 func (ee *ee) FmtDateLong(t time.Time) string {
445
446 b := make([]byte, 0, 32)
447
448 b = append(b, ee.monthsWide[t.Month()]...)
449 b = append(b, []byte{0x20}...)
450 b = strconv.AppendInt(b, int64(t.Day()), 10)
451 b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...)
452 b = append(b, []byte{0x20}...)
453
454 if t.Year() > 0 {
455 b = strconv.AppendInt(b, int64(t.Year()), 10)
456 } else {
457 b = strconv.AppendInt(b, int64(-t.Year()), 10)
458 }
459
460 return string(b)
461 }
462
463
464 func (ee *ee) FmtDateFull(t time.Time) string {
465
466 b := make([]byte, 0, 32)
467
468 b = append(b, ee.daysWide[t.Weekday()]...)
469 b = append(b, []byte{0x2c, 0x20}...)
470 b = append(b, ee.monthsWide[t.Month()]...)
471 b = append(b, []byte{0x20}...)
472 b = strconv.AppendInt(b, int64(t.Day()), 10)
473 b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...)
474 b = append(b, []byte{0x20}...)
475
476 if t.Year() > 0 {
477 b = strconv.AppendInt(b, int64(t.Year()), 10)
478 } else {
479 b = strconv.AppendInt(b, int64(-t.Year()), 10)
480 }
481
482 return string(b)
483 }
484
485
486 func (ee *ee) FmtTimeShort(t time.Time) string {
487
488 b := make([]byte, 0, 32)
489
490 if t.Hour() < 12 {
491 b = append(b, ee.periodsAbbreviated[0]...)
492 } else {
493 b = append(b, ee.periodsAbbreviated[1]...)
494 }
495
496 b = append(b, []byte{0x20, 0x67, 0x61}...)
497 b = append(b, []byte{0x20}...)
498
499 h := t.Hour()
500
501 if h > 12 {
502 h -= 12
503 }
504
505 b = strconv.AppendInt(b, int64(h), 10)
506 b = append(b, ee.timeSeparator...)
507
508 if t.Minute() < 10 {
509 b = append(b, '0')
510 }
511
512 b = strconv.AppendInt(b, int64(t.Minute()), 10)
513
514 return string(b)
515 }
516
517
518 func (ee *ee) FmtTimeMedium(t time.Time) string {
519
520 b := make([]byte, 0, 32)
521
522 if t.Hour() < 12 {
523 b = append(b, ee.periodsAbbreviated[0]...)
524 } else {
525 b = append(b, ee.periodsAbbreviated[1]...)
526 }
527
528 b = append(b, []byte{0x20, 0x67, 0x61}...)
529 b = append(b, []byte{0x20}...)
530
531 h := t.Hour()
532
533 if h > 12 {
534 h -= 12
535 }
536
537 b = strconv.AppendInt(b, int64(h), 10)
538 b = append(b, ee.timeSeparator...)
539
540 if t.Minute() < 10 {
541 b = append(b, '0')
542 }
543
544 b = strconv.AppendInt(b, int64(t.Minute()), 10)
545 b = append(b, ee.timeSeparator...)
546
547 if t.Second() < 10 {
548 b = append(b, '0')
549 }
550
551 b = strconv.AppendInt(b, int64(t.Second()), 10)
552
553 return string(b)
554 }
555
556
557 func (ee *ee) FmtTimeLong(t time.Time) string {
558
559 b := make([]byte, 0, 32)
560
561 if t.Hour() < 12 {
562 b = append(b, ee.periodsAbbreviated[0]...)
563 } else {
564 b = append(b, ee.periodsAbbreviated[1]...)
565 }
566
567 b = append(b, []byte{0x20, 0x67, 0x61}...)
568 b = append(b, []byte{0x20}...)
569
570 h := t.Hour()
571
572 if h > 12 {
573 h -= 12
574 }
575
576 b = strconv.AppendInt(b, int64(h), 10)
577 b = append(b, ee.timeSeparator...)
578
579 if t.Minute() < 10 {
580 b = append(b, '0')
581 }
582
583 b = strconv.AppendInt(b, int64(t.Minute()), 10)
584 b = append(b, ee.timeSeparator...)
585
586 if t.Second() < 10 {
587 b = append(b, '0')
588 }
589
590 b = strconv.AppendInt(b, int64(t.Second()), 10)
591 b = append(b, []byte{0x20}...)
592
593 tz, _ := t.Zone()
594 b = append(b, tz...)
595
596 return string(b)
597 }
598
599
600 func (ee *ee) FmtTimeFull(t time.Time) string {
601
602 b := make([]byte, 0, 32)
603
604 if t.Hour() < 12 {
605 b = append(b, ee.periodsAbbreviated[0]...)
606 } else {
607 b = append(b, ee.periodsAbbreviated[1]...)
608 }
609
610 b = append(b, []byte{0x20, 0x67, 0x61}...)
611 b = append(b, []byte{0x20}...)
612
613 h := t.Hour()
614
615 if h > 12 {
616 h -= 12
617 }
618
619 b = strconv.AppendInt(b, int64(h), 10)
620 b = append(b, ee.timeSeparator...)
621
622 if t.Minute() < 10 {
623 b = append(b, '0')
624 }
625
626 b = strconv.AppendInt(b, int64(t.Minute()), 10)
627 b = append(b, ee.timeSeparator...)
628
629 if t.Second() < 10 {
630 b = append(b, '0')
631 }
632
633 b = strconv.AppendInt(b, int64(t.Second()), 10)
634 b = append(b, []byte{0x20}...)
635
636 tz, _ := t.Zone()
637
638 if btz, ok := ee.timezones[tz]; ok {
639 b = append(b, btz...)
640 } else {
641 b = append(b, tz...)
642 }
643
644 return string(b)
645 }
646
View as plain text