1 package zu
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 zu 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 &zu{
47 locale: "zu",
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{2, 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", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$", "ATS", "A$", "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", "GHS", "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", "Db", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "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", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "Jan", "Feb", "Mas", "Eph", "Mey", "Jun", "Jul", "Aga", "Sep", "Okt", "Nov", "Dis"},
62 monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "A", "S", "O", "N", "D"},
63 monthsWide: []string{"", "Januwari", "Februwari", "Mashi", "Ephreli", "Meyi", "Juni", "Julayi", "Agasti", "Septhemba", "Okthoba", "Novemba", "Disemba"},
64 daysAbbreviated: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"},
65 daysNarrow: []string{"S", "M", "B", "T", "S", "H", "M"},
66 daysShort: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"},
67 daysWide: []string{"ISonto", "UMsombuluko", "ULwesibili", "ULwesithathu", "ULwesine", "ULwesihlanu", "UMgqibelo"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsNarrow: []string{"a", "p"},
70 periodsWide: []string{"AM", "PM"},
71 erasAbbreviated: []string{"BC", "AD"},
72 erasNarrow: []string{"", ""},
73 erasWide: []string{"BC", "AD"},
74 timezones: map[string]string{"ACDT": "Isikhathi sase-Australian Central sasemini", "ACST": "Isikhathi sase-Australian Central esivamile", "ACWDT": "Isikhathi sasemini sase-Australian Central West", "ACWST": "Isikhathi sase-Australian Central West esivamile", "ADT": "Isikhathi sase-Atlantic sasemini", "AEDT": "Isikhathi sasemini sase-Australian East", "AEST": "Isikhathi esivamile sase-Australian East", "AKDT": "Isikhathi sase-Alaska sasemini", "AKST": "Isikhathi sase-Alaska esijwayelekile", "ARST": "Isikhathi sase-Argentina sasehlobo", "ART": "Isikhathi sase-Argentina esijwayelekile", "AST": "Isikhathi sase-Atlantic esijwayelekile", "AWDT": "Isikhathi sase-Australian Western sasemini", "AWST": "Isikhathi sase-Australian Western esivamile", "BOT": "Isikhathi sase-Bolivia", "BT": "Isikhathi sase-Bhutan", "CAT": "Isikhathi sase-Central Africa", "CDT": "Isikhathi sase-North American Central sasemini", "CHADT": "Isikhathi sasemini sase-Chatham", "CHAST": "Isikhathi esivamile sase-Chatham", "CLST": "Isikhathi sase-Chile sasehlobo", "CLT": "Isikhathi sase-Chile esijwayelekile", "COST": "Isikhathi sase-Colombia sasehlobo", "COT": "Isikhathi sase-Colombia esijwayelekile", "CST": "Isikhathi sase-North American Central esijwayelekile", "ChST": "Isikhathi esivamile sase-Chamorro", "EAT": "Isikhathi saseMpumalanga Afrika", "ECT": "Isikhathi sase-Ecuador", "EDT": "Isikhathi sase-North American East sasemini", "EST": "Isikhathi sase-North American East esijwayelekile", "GFT": "Isikhathi sase-French Guiana", "GMT": "Isikhathi sase-Greenwich Mean", "GST": "Isikhathi esivamile sase-Gulf", "GYT": "Isikhathi sase-Guyana", "HADT": "Isikhathi sase-Hawaii-Aleutia sasemini", "HAST": "Isikhathi sase-Hawaii-Aleutia esijwayelekile", "HAT": "Isikhathi sase-Newfoundland sasemini", "HECU": "Isikhathi sase-Cuba sasemini", "HEEG": "Isikhathi sase-East Greenland sasemini", "HENOMX": "Isikhathi sase-Northwest Mexico sasemini", "HEOG": "Isikhathi sase-West Greenland sasehlobo", "HEPM": "Isikhathi sase-Saint Pierre nase-Miquelon sasemini", "HEPMX": "Isikhathi sase-Mexican Pacific sasemini", "HKST": "Isikhathi sehlobo sase-Hong Kong", "HKT": "Isikhathi esivamile sase-Hong Kong", "HNCU": "Isikhathi sase-Cuba esijwayelekile", "HNEG": "Isikhathi sase-East Greenland esijwayelekile", "HNNOMX": "Isikhathi sase-Northwest Mexico esijwayelekile", "HNOG": "Isikhathi sase-West Greenland esijwayelekile", "HNPM": "Iikhathi sase-Saint Pierre nase-Miquelon esijwayelekile", "HNPMX": "Isikhathi sase-Mexican Pacific esijwayelekile", "HNT": "Isikhathi sase-Newfoundland esijwayelekile", "IST": "Isikhathi sase-India esivamile", "JDT": "Isikhathi semini sase-Japan", "JST": "Isikhathi esivamile sase-Japan", "LHDT": "Isikhathi sase-Lord Howe sasemini", "LHST": "Isikhathi sase-Lord Howe esivamile", "MDT": "Isikhathi sase-North American Mountain sasemini", "MESZ": "Isikhathi sasehlobo sase-Central Europe", "MEZ": "Isikhathi esijwayelekile sase-Central Europe", "MST": "Isikhathi sase-North American Mountain esijwayelekile", "MYT": "Isikhathi sase-Malaysia", "NZDT": "Isikhathi sasemini sase-New Zealand", "NZST": "Isikhathi esivamile sase-New Zealand", "OESZ": "Isikhathi sasehlobo sase-Eastern Europe", "OEZ": "Isikhathi esijwayelekile sase-Eastern Europe", "PDT": "Isikhathi sase-North American Pacific sasemini", "PST": "Isikhathi sase-North American Pacific esijwayelekile", "SAST": "Isikhathi esivamile saseNingizimu Afrika", "SGT": "Isikhathi esivamile sase-Singapore", "SRT": "Isikhathi sase-Suriname", "TMST": "Isikhathi sehlobo sase-Turkmenistan", "TMT": "Isikhathi esivamile sase-Turkmenistan", "UYST": "Isikhathi sase-Uruguay sasehlobo", "UYT": "Isikhathi sase-Uruguay esijwayelekile", "VET": "Isikhathi sase-Venezuela", "WARST": "Isikhathi saseNyakatho ne-Argentina sasehlobo", "WART": "Isikhathi saseNyakatho ne-Argentina esijwayelekile", "WAST": "Isikhathi sasehlobo saseNtshonalanga Afrika", "WAT": "Isikhathi esivamile saseNtshonalanga Afrika", "WESZ": "Isikhathi sasehlobo sase-Western Europe", "WEZ": "Isikhathi esijwayelekile sase-Western Europe", "WIB": "Isikhathi sase-Western Indonesia", "WIT": "Isikhathi sase-Eastern Indonesia", "WITA": "Isikhathi sase-Central Indonesia", "∅∅∅": "Isikhathi sase-Brasilia sasehlobo"},
75 }
76 }
77
78
79 func (zu *zu) Locale() string {
80 return zu.locale
81 }
82
83
84 func (zu *zu) PluralsCardinal() []locales.PluralRule {
85 return zu.pluralsCardinal
86 }
87
88
89 func (zu *zu) PluralsOrdinal() []locales.PluralRule {
90 return zu.pluralsOrdinal
91 }
92
93
94 func (zu *zu) PluralsRange() []locales.PluralRule {
95 return zu.pluralsRange
96 }
97
98
99 func (zu *zu) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101 n := math.Abs(num)
102 i := int64(n)
103
104 if (i == 0) || (n == 1) {
105 return locales.PluralRuleOne
106 }
107
108 return locales.PluralRuleOther
109 }
110
111
112 func (zu *zu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113 return locales.PluralRuleOther
114 }
115
116
117 func (zu *zu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
118
119 start := zu.CardinalPluralRule(num1, v1)
120 end := zu.CardinalPluralRule(num2, v2)
121
122 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
123 return locales.PluralRuleOne
124 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
125 return locales.PluralRuleOther
126 }
127
128 return locales.PluralRuleOther
129
130 }
131
132
133 func (zu *zu) MonthAbbreviated(month time.Month) string {
134 return zu.monthsAbbreviated[month]
135 }
136
137
138 func (zu *zu) MonthsAbbreviated() []string {
139 return zu.monthsAbbreviated[1:]
140 }
141
142
143 func (zu *zu) MonthNarrow(month time.Month) string {
144 return zu.monthsNarrow[month]
145 }
146
147
148 func (zu *zu) MonthsNarrow() []string {
149 return zu.monthsNarrow[1:]
150 }
151
152
153 func (zu *zu) MonthWide(month time.Month) string {
154 return zu.monthsWide[month]
155 }
156
157
158 func (zu *zu) MonthsWide() []string {
159 return zu.monthsWide[1:]
160 }
161
162
163 func (zu *zu) WeekdayAbbreviated(weekday time.Weekday) string {
164 return zu.daysAbbreviated[weekday]
165 }
166
167
168 func (zu *zu) WeekdaysAbbreviated() []string {
169 return zu.daysAbbreviated
170 }
171
172
173 func (zu *zu) WeekdayNarrow(weekday time.Weekday) string {
174 return zu.daysNarrow[weekday]
175 }
176
177
178 func (zu *zu) WeekdaysNarrow() []string {
179 return zu.daysNarrow
180 }
181
182
183 func (zu *zu) WeekdayShort(weekday time.Weekday) string {
184 return zu.daysShort[weekday]
185 }
186
187
188 func (zu *zu) WeekdaysShort() []string {
189 return zu.daysShort
190 }
191
192
193 func (zu *zu) WeekdayWide(weekday time.Weekday) string {
194 return zu.daysWide[weekday]
195 }
196
197
198 func (zu *zu) WeekdaysWide() []string {
199 return zu.daysWide
200 }
201
202
203 func (zu *zu) Decimal() string {
204 return zu.decimal
205 }
206
207
208 func (zu *zu) Group() string {
209 return zu.group
210 }
211
212
213 func (zu *zu) Minus() string {
214 return zu.minus
215 }
216
217
218 func (zu *zu) FmtNumber(num float64, v uint64) string {
219
220 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
221 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
222 count := 0
223 inWhole := v == 0
224 b := make([]byte, 0, l)
225
226 for i := len(s) - 1; i >= 0; i-- {
227
228 if s[i] == '.' {
229 b = append(b, zu.decimal[0])
230 inWhole = true
231 continue
232 }
233
234 if inWhole {
235 if count == 3 {
236 b = append(b, zu.group[0])
237 count = 1
238 } else {
239 count++
240 }
241 }
242
243 b = append(b, s[i])
244 }
245
246 if num < 0 {
247 b = append(b, zu.minus[0])
248 }
249
250
251 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
252 b[i], b[j] = b[j], b[i]
253 }
254
255 return string(b)
256 }
257
258
259
260 func (zu *zu) FmtPercent(num float64, v uint64) string {
261 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
262 l := len(s) + 3
263 b := make([]byte, 0, l)
264
265 for i := len(s) - 1; i >= 0; i-- {
266
267 if s[i] == '.' {
268 b = append(b, zu.decimal[0])
269 continue
270 }
271
272 b = append(b, s[i])
273 }
274
275 if num < 0 {
276 b = append(b, zu.minus[0])
277 }
278
279
280 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
281 b[i], b[j] = b[j], b[i]
282 }
283
284 b = append(b, zu.percent...)
285
286 return string(b)
287 }
288
289
290 func (zu *zu) FmtCurrency(num float64, v uint64, currency currency.Type) string {
291
292 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
293 symbol := zu.currencies[currency]
294 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
295 count := 0
296 inWhole := v == 0
297 b := make([]byte, 0, l)
298
299 for i := len(s) - 1; i >= 0; i-- {
300
301 if s[i] == '.' {
302 b = append(b, zu.decimal[0])
303 inWhole = true
304 continue
305 }
306
307 if inWhole {
308 if count == 3 {
309 b = append(b, zu.group[0])
310 count = 1
311 } else {
312 count++
313 }
314 }
315
316 b = append(b, s[i])
317 }
318
319 for j := len(symbol) - 1; j >= 0; j-- {
320 b = append(b, symbol[j])
321 }
322
323 if num < 0 {
324 b = append(b, zu.minus[0])
325 }
326
327
328 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
329 b[i], b[j] = b[j], b[i]
330 }
331
332 if int(v) < 2 {
333
334 if v == 0 {
335 b = append(b, zu.decimal...)
336 }
337
338 for i := 0; i < 2-int(v); i++ {
339 b = append(b, '0')
340 }
341 }
342
343 return string(b)
344 }
345
346
347
348 func (zu *zu) FmtAccounting(num float64, v uint64, currency currency.Type) string {
349
350 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
351 symbol := zu.currencies[currency]
352 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
353 count := 0
354 inWhole := v == 0
355 b := make([]byte, 0, l)
356
357 for i := len(s) - 1; i >= 0; i-- {
358
359 if s[i] == '.' {
360 b = append(b, zu.decimal[0])
361 inWhole = true
362 continue
363 }
364
365 if inWhole {
366 if count == 3 {
367 b = append(b, zu.group[0])
368 count = 1
369 } else {
370 count++
371 }
372 }
373
374 b = append(b, s[i])
375 }
376
377 if num < 0 {
378
379 for j := len(symbol) - 1; j >= 0; j-- {
380 b = append(b, symbol[j])
381 }
382
383 b = append(b, zu.currencyNegativePrefix[0])
384
385 } else {
386
387 for j := len(symbol) - 1; j >= 0; j-- {
388 b = append(b, symbol[j])
389 }
390
391 }
392
393
394 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
395 b[i], b[j] = b[j], b[i]
396 }
397
398 if int(v) < 2 {
399
400 if v == 0 {
401 b = append(b, zu.decimal...)
402 }
403
404 for i := 0; i < 2-int(v); i++ {
405 b = append(b, '0')
406 }
407 }
408
409 if num < 0 {
410 b = append(b, zu.currencyNegativeSuffix...)
411 }
412
413 return string(b)
414 }
415
416
417 func (zu *zu) FmtDateShort(t time.Time) string {
418
419 b := make([]byte, 0, 32)
420
421 b = strconv.AppendInt(b, int64(t.Month()), 10)
422 b = append(b, []byte{0x2f}...)
423 b = strconv.AppendInt(b, int64(t.Day()), 10)
424 b = append(b, []byte{0x2f}...)
425
426 if t.Year() > 9 {
427 b = append(b, strconv.Itoa(t.Year())[2:]...)
428 } else {
429 b = append(b, strconv.Itoa(t.Year())[1:]...)
430 }
431
432 return string(b)
433 }
434
435
436 func (zu *zu) FmtDateMedium(t time.Time) string {
437
438 b := make([]byte, 0, 32)
439
440 b = append(b, zu.monthsAbbreviated[t.Month()]...)
441 b = append(b, []byte{0x20}...)
442 b = strconv.AppendInt(b, int64(t.Day()), 10)
443 b = append(b, []byte{0x2c, 0x20}...)
444
445 if t.Year() > 0 {
446 b = strconv.AppendInt(b, int64(t.Year()), 10)
447 } else {
448 b = strconv.AppendInt(b, int64(-t.Year()), 10)
449 }
450
451 return string(b)
452 }
453
454
455 func (zu *zu) FmtDateLong(t time.Time) string {
456
457 b := make([]byte, 0, 32)
458
459 b = append(b, zu.monthsWide[t.Month()]...)
460 b = append(b, []byte{0x20}...)
461 b = strconv.AppendInt(b, int64(t.Day()), 10)
462 b = append(b, []byte{0x2c, 0x20}...)
463
464 if t.Year() > 0 {
465 b = strconv.AppendInt(b, int64(t.Year()), 10)
466 } else {
467 b = strconv.AppendInt(b, int64(-t.Year()), 10)
468 }
469
470 return string(b)
471 }
472
473
474 func (zu *zu) FmtDateFull(t time.Time) string {
475
476 b := make([]byte, 0, 32)
477
478 b = append(b, zu.daysWide[t.Weekday()]...)
479 b = append(b, []byte{0x2c, 0x20}...)
480 b = append(b, zu.monthsWide[t.Month()]...)
481 b = append(b, []byte{0x20}...)
482 b = strconv.AppendInt(b, int64(t.Day()), 10)
483 b = append(b, []byte{0x2c, 0x20}...)
484
485 if t.Year() > 0 {
486 b = strconv.AppendInt(b, int64(t.Year()), 10)
487 } else {
488 b = strconv.AppendInt(b, int64(-t.Year()), 10)
489 }
490
491 return string(b)
492 }
493
494
495 func (zu *zu) FmtTimeShort(t time.Time) string {
496
497 b := make([]byte, 0, 32)
498
499 if t.Hour() < 10 {
500 b = append(b, '0')
501 }
502
503 b = strconv.AppendInt(b, int64(t.Hour()), 10)
504 b = append(b, zu.timeSeparator...)
505
506 if t.Minute() < 10 {
507 b = append(b, '0')
508 }
509
510 b = strconv.AppendInt(b, int64(t.Minute()), 10)
511
512 return string(b)
513 }
514
515
516 func (zu *zu) FmtTimeMedium(t time.Time) string {
517
518 b := make([]byte, 0, 32)
519
520 if t.Hour() < 10 {
521 b = append(b, '0')
522 }
523
524 b = strconv.AppendInt(b, int64(t.Hour()), 10)
525 b = append(b, zu.timeSeparator...)
526
527 if t.Minute() < 10 {
528 b = append(b, '0')
529 }
530
531 b = strconv.AppendInt(b, int64(t.Minute()), 10)
532 b = append(b, zu.timeSeparator...)
533
534 if t.Second() < 10 {
535 b = append(b, '0')
536 }
537
538 b = strconv.AppendInt(b, int64(t.Second()), 10)
539
540 return string(b)
541 }
542
543
544 func (zu *zu) FmtTimeLong(t time.Time) string {
545
546 b := make([]byte, 0, 32)
547
548 if t.Hour() < 10 {
549 b = append(b, '0')
550 }
551
552 b = strconv.AppendInt(b, int64(t.Hour()), 10)
553 b = append(b, zu.timeSeparator...)
554
555 if t.Minute() < 10 {
556 b = append(b, '0')
557 }
558
559 b = strconv.AppendInt(b, int64(t.Minute()), 10)
560 b = append(b, zu.timeSeparator...)
561
562 if t.Second() < 10 {
563 b = append(b, '0')
564 }
565
566 b = strconv.AppendInt(b, int64(t.Second()), 10)
567 b = append(b, []byte{0x20}...)
568
569 tz, _ := t.Zone()
570 b = append(b, tz...)
571
572 return string(b)
573 }
574
575
576 func (zu *zu) FmtTimeFull(t time.Time) string {
577
578 b := make([]byte, 0, 32)
579
580 if t.Hour() < 10 {
581 b = append(b, '0')
582 }
583
584 b = strconv.AppendInt(b, int64(t.Hour()), 10)
585 b = append(b, zu.timeSeparator...)
586
587 if t.Minute() < 10 {
588 b = append(b, '0')
589 }
590
591 b = strconv.AppendInt(b, int64(t.Minute()), 10)
592 b = append(b, zu.timeSeparator...)
593
594 if t.Second() < 10 {
595 b = append(b, '0')
596 }
597
598 b = strconv.AppendInt(b, int64(t.Second()), 10)
599 b = append(b, []byte{0x20}...)
600
601 tz, _ := t.Zone()
602
603 if btz, ok := zu.timezones[tz]; ok {
604 b = append(b, btz...)
605 } else {
606 b = append(b, tz...)
607 }
608
609 return string(b)
610 }
611
View as plain text