1 package pl
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 pl 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 currencyPositiveSuffix string
26 currencyNegativePrefix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
29 monthsNarrow []string
30 monthsWide []string
31 daysAbbreviated []string
32 daysNarrow []string
33 daysShort []string
34 daysWide []string
35 periodsAbbreviated []string
36 periodsNarrow []string
37 periodsShort []string
38 periodsWide []string
39 erasAbbreviated []string
40 erasNarrow []string
41 erasWide []string
42 timezones map[string]string
43 }
44
45
46 func New() locales.Translator {
47 return &pl{
48 locale: "pl",
49 pluralsCardinal: []locales.PluralRule{2, 4, 5, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{2, 4, 5, 6},
52 decimal: ",",
53 group: " ",
54 minus: "-",
55 percent: "%",
56 perMille: "‰",
57 timeSeparator: ":",
58 inifinity: "∞",
59 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", "zł", "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"},
60 currencyPositiveSuffix: " ",
61 currencyNegativePrefix: "(",
62 currencyNegativeSuffix: " )",
63 monthsAbbreviated: []string{"", "sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paź", "lis", "gru"},
64 monthsNarrow: []string{"", "s", "l", "m", "k", "m", "c", "l", "s", "w", "p", "l", "g"},
65 monthsWide: []string{"", "stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"},
66 daysAbbreviated: []string{"niedz.", "pon.", "wt.", "śr.", "czw.", "pt.", "sob."},
67 daysNarrow: []string{"n", "p", "w", "ś", "c", "p", "s"},
68 daysShort: []string{"nie", "pon", "wto", "śro", "czw", "pią", "sob"},
69 daysWide: []string{"niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"},
70 periodsAbbreviated: []string{"AM", "PM"},
71 periodsNarrow: []string{"a", "p"},
72 periodsWide: []string{"AM", "PM"},
73 erasAbbreviated: []string{"p.n.e.", "n.e."},
74 erasNarrow: []string{"", ""},
75 erasWide: []string{"przed naszą erą", "naszej ery"},
76 timezones: map[string]string{"ACDT": "czas środkowoaustralijski letni", "ACST": "czas środkowoaustralijski standardowy", "ACWDT": "czas środkowo-zachodnioaustralijski letni", "ACWST": "czas środkowo-zachodnioaustralijski standardowy", "ADT": "czas atlantycki letni", "AEDT": "czas wschodnioaustralijski letni", "AEST": "czas wschodnioaustralijski standardowy", "AKDT": "Alaska (czas letni)", "AKST": "Alaska (czas standardowy)", "ARST": "Argentyna (czas letni)", "ART": "Argentyna (czas standardowy)", "AST": "czas atlantycki standardowy", "AWDT": "czas zachodnioaustralijski letni", "AWST": "czas zachodnioaustralijski standardowy", "BOT": "Boliwia", "BT": "Bhutan", "CAT": "czas środkowoafrykański", "CDT": "czas środkowoamerykański letni", "CHADT": "Chatham (czas letni)", "CHAST": "Chatham (czas standardowy)", "CLST": "Chile (czas letni)", "CLT": "Chile (czas standardowy)", "COST": "Kolumbia (czas letni)", "COT": "Kolumbia (czas standardowy)", "CST": "czas środkowoamerykański standardowy", "ChST": "Czamorro", "EAT": "czas wschodnioafrykański", "ECT": "Ekwador", "EDT": "czas wschodnioamerykański letni", "EST": "czas wschodnioamerykański standardowy", "GFT": "Gujana Francuska", "GMT": "czas uniwersalny", "GST": "Zatoka Perska", "GYT": "Gujana", "HADT": "Hawaje-Aleuty (czas letni)", "HAST": "Hawaje-Aleuty (czas standardowy)", "HAT": "Nowa Fundlandia (czas letni)", "HECU": "Kuba (czas letni)", "HEEG": "Grenlandia Wschodnia (czas letni)", "HENOMX": "Meksyk Północno-Zachodni (czas letni)", "HEOG": "Grenlandia Zachodnia (czas letni)", "HEPM": "Saint-Pierre i Miquelon (czas letni)", "HEPMX": "Meksyk (czas pacyficzny letni)", "HKST": "Hongkong (czas letni)", "HKT": "Hongkong (czas standardowy)", "HNCU": "Kuba (czas standardowy)", "HNEG": "Grenlandia Wschodnia (czas standardowy)", "HNNOMX": "Meksyk Północno-Zachodni (czas standardowy)", "HNOG": "Grenlandia Zachodnia (czas standardowy)", "HNPM": "Saint-Pierre i Miquelon (czas standardowy)", "HNPMX": "Meksyk (czas pacyficzny standardowy)", "HNT": "Nowa Fundlandia (czas standardowy)", "IST": "czas indyjski standardowy", "JDT": "Japonia (czas letni)", "JST": "Japonia (czas standardowy)", "LHDT": "Lord Howe (czas letni)", "LHST": "Lord Howe (czas standardowy)", "MDT": "czas górski letni", "MESZ": "czas środkowoeuropejski letni", "MEZ": "czas środkowoeuropejski standardowy", "MST": "czas górski standardowy", "MYT": "Malezja", "NZDT": "Nowa Zelandia (czas letni)", "NZST": "Nowa Zelandia (czas standardowy)", "OESZ": "czas wschodnioeuropejski letni", "OEZ": "czas wschodnioeuropejski standardowy", "PDT": "czas pacyficzny letni", "PST": "czas pacyficzny standardowy", "SAST": "czas południowoafrykański", "SGT": "Singapur", "SRT": "Surinam", "TMST": "Turkmenistan (czas letni)", "TMT": "Turkmenistan (czas standardowy)", "UYST": "Urugwaj (czas letni)", "UYT": "Urugwaj (czas standardowy)", "VET": "Wenezuela", "WARST": "Argentyna Zachodnia (czas letni)", "WART": "Argentyna Zachodnia (czas standardowy)", "WAST": "czas zachodnioafrykański letni", "WAT": "czas zachodnioafrykański standardowy", "WESZ": "czas zachodnioeuropejski letni", "WEZ": "czas zachodnioeuropejski standardowy", "WIB": "Indonezja Zachodnia", "WIT": "Indonezja Wschodnia", "WITA": "Indonezja Środkowa", "∅∅∅": "Azory (czas letni)"},
77 }
78 }
79
80
81 func (pl *pl) Locale() string {
82 return pl.locale
83 }
84
85
86 func (pl *pl) PluralsCardinal() []locales.PluralRule {
87 return pl.pluralsCardinal
88 }
89
90
91 func (pl *pl) PluralsOrdinal() []locales.PluralRule {
92 return pl.pluralsOrdinal
93 }
94
95
96 func (pl *pl) PluralsRange() []locales.PluralRule {
97 return pl.pluralsRange
98 }
99
100
101 func (pl *pl) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
102
103 n := math.Abs(num)
104 i := int64(n)
105 iMod100 := i % 100
106 iMod10 := i % 10
107
108 if i == 1 && v == 0 {
109 return locales.PluralRuleOne
110 } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) {
111 return locales.PluralRuleFew
112 } else if (v == 0 && i != 1 && iMod10 >= 0 && iMod10 <= 1) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 12 && iMod100 <= 14) {
113 return locales.PluralRuleMany
114 }
115
116 return locales.PluralRuleOther
117 }
118
119
120 func (pl *pl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
121 return locales.PluralRuleOther
122 }
123
124
125 func (pl *pl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
126
127 start := pl.CardinalPluralRule(num1, v1)
128 end := pl.CardinalPluralRule(num2, v2)
129
130 if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
131 return locales.PluralRuleFew
132 } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany {
133 return locales.PluralRuleMany
134 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
135 return locales.PluralRuleOther
136 } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
137 return locales.PluralRuleFew
138 } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany {
139 return locales.PluralRuleMany
140 } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
141 return locales.PluralRuleOther
142 } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne {
143 return locales.PluralRuleOne
144 } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew {
145 return locales.PluralRuleFew
146 } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany {
147 return locales.PluralRuleMany
148 } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther {
149 return locales.PluralRuleOther
150 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
151 return locales.PluralRuleOne
152 } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
153 return locales.PluralRuleFew
154 } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany {
155 return locales.PluralRuleMany
156 }
157
158 return locales.PluralRuleOther
159
160 }
161
162
163 func (pl *pl) MonthAbbreviated(month time.Month) string {
164 return pl.monthsAbbreviated[month]
165 }
166
167
168 func (pl *pl) MonthsAbbreviated() []string {
169 return pl.monthsAbbreviated[1:]
170 }
171
172
173 func (pl *pl) MonthNarrow(month time.Month) string {
174 return pl.monthsNarrow[month]
175 }
176
177
178 func (pl *pl) MonthsNarrow() []string {
179 return pl.monthsNarrow[1:]
180 }
181
182
183 func (pl *pl) MonthWide(month time.Month) string {
184 return pl.monthsWide[month]
185 }
186
187
188 func (pl *pl) MonthsWide() []string {
189 return pl.monthsWide[1:]
190 }
191
192
193 func (pl *pl) WeekdayAbbreviated(weekday time.Weekday) string {
194 return pl.daysAbbreviated[weekday]
195 }
196
197
198 func (pl *pl) WeekdaysAbbreviated() []string {
199 return pl.daysAbbreviated
200 }
201
202
203 func (pl *pl) WeekdayNarrow(weekday time.Weekday) string {
204 return pl.daysNarrow[weekday]
205 }
206
207
208 func (pl *pl) WeekdaysNarrow() []string {
209 return pl.daysNarrow
210 }
211
212
213 func (pl *pl) WeekdayShort(weekday time.Weekday) string {
214 return pl.daysShort[weekday]
215 }
216
217
218 func (pl *pl) WeekdaysShort() []string {
219 return pl.daysShort
220 }
221
222
223 func (pl *pl) WeekdayWide(weekday time.Weekday) string {
224 return pl.daysWide[weekday]
225 }
226
227
228 func (pl *pl) WeekdaysWide() []string {
229 return pl.daysWide
230 }
231
232
233 func (pl *pl) Decimal() string {
234 return pl.decimal
235 }
236
237
238 func (pl *pl) Group() string {
239 return pl.group
240 }
241
242
243 func (pl *pl) Minus() string {
244 return pl.minus
245 }
246
247
248 func (pl *pl) FmtNumber(num float64, v uint64) string {
249
250 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
251 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
252 count := 0
253 inWhole := v == 0
254 b := make([]byte, 0, l)
255
256 for i := len(s) - 1; i >= 0; i-- {
257
258 if s[i] == '.' {
259 b = append(b, pl.decimal[0])
260 inWhole = true
261 continue
262 }
263
264 if inWhole {
265 if count == 3 {
266 for j := len(pl.group) - 1; j >= 0; j-- {
267 b = append(b, pl.group[j])
268 }
269 count = 1
270 } else {
271 count++
272 }
273 }
274
275 b = append(b, s[i])
276 }
277
278 if num < 0 {
279 b = append(b, pl.minus[0])
280 }
281
282
283 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
284 b[i], b[j] = b[j], b[i]
285 }
286
287 return string(b)
288 }
289
290
291
292 func (pl *pl) FmtPercent(num float64, v uint64) string {
293 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
294 l := len(s) + 3
295 b := make([]byte, 0, l)
296
297 for i := len(s) - 1; i >= 0; i-- {
298
299 if s[i] == '.' {
300 b = append(b, pl.decimal[0])
301 continue
302 }
303
304 b = append(b, s[i])
305 }
306
307 if num < 0 {
308 b = append(b, pl.minus[0])
309 }
310
311
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
314 }
315
316 b = append(b, pl.percent...)
317
318 return string(b)
319 }
320
321
322 func (pl *pl) FmtCurrency(num float64, v uint64, currency currency.Type) string {
323
324 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
325 symbol := pl.currencies[currency]
326 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
327 count := 0
328 inWhole := v == 0
329 b := make([]byte, 0, l)
330
331 for i := len(s) - 1; i >= 0; i-- {
332
333 if s[i] == '.' {
334 b = append(b, pl.decimal[0])
335 inWhole = true
336 continue
337 }
338
339 if inWhole {
340 if count == 3 {
341 for j := len(pl.group) - 1; j >= 0; j-- {
342 b = append(b, pl.group[j])
343 }
344 count = 1
345 } else {
346 count++
347 }
348 }
349
350 b = append(b, s[i])
351 }
352
353 if num < 0 {
354 b = append(b, pl.minus[0])
355 }
356
357
358 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
359 b[i], b[j] = b[j], b[i]
360 }
361
362 if int(v) < 2 {
363
364 if v == 0 {
365 b = append(b, pl.decimal...)
366 }
367
368 for i := 0; i < 2-int(v); i++ {
369 b = append(b, '0')
370 }
371 }
372
373 b = append(b, pl.currencyPositiveSuffix...)
374
375 b = append(b, symbol...)
376
377 return string(b)
378 }
379
380
381
382 func (pl *pl) FmtAccounting(num float64, v uint64, currency currency.Type) string {
383
384 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
385 symbol := pl.currencies[currency]
386 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
387 count := 0
388 inWhole := v == 0
389 b := make([]byte, 0, l)
390
391 for i := len(s) - 1; i >= 0; i-- {
392
393 if s[i] == '.' {
394 b = append(b, pl.decimal[0])
395 inWhole = true
396 continue
397 }
398
399 if inWhole {
400 if count == 3 {
401 for j := len(pl.group) - 1; j >= 0; j-- {
402 b = append(b, pl.group[j])
403 }
404 count = 1
405 } else {
406 count++
407 }
408 }
409
410 b = append(b, s[i])
411 }
412
413 if num < 0 {
414
415 b = append(b, pl.currencyNegativePrefix[0])
416
417 }
418
419
420 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
421 b[i], b[j] = b[j], b[i]
422 }
423
424 if int(v) < 2 {
425
426 if v == 0 {
427 b = append(b, pl.decimal...)
428 }
429
430 for i := 0; i < 2-int(v); i++ {
431 b = append(b, '0')
432 }
433 }
434
435 if num < 0 {
436 b = append(b, pl.currencyNegativeSuffix...)
437 b = append(b, symbol...)
438 } else {
439
440 b = append(b, pl.currencyPositiveSuffix...)
441 b = append(b, symbol...)
442 }
443
444 return string(b)
445 }
446
447
448 func (pl *pl) FmtDateShort(t time.Time) string {
449
450 b := make([]byte, 0, 32)
451
452 if t.Day() < 10 {
453 b = append(b, '0')
454 }
455
456 b = strconv.AppendInt(b, int64(t.Day()), 10)
457 b = append(b, []byte{0x2e}...)
458
459 if t.Month() < 10 {
460 b = append(b, '0')
461 }
462
463 b = strconv.AppendInt(b, int64(t.Month()), 10)
464
465 b = append(b, []byte{0x2e}...)
466
467 if t.Year() > 0 {
468 b = strconv.AppendInt(b, int64(t.Year()), 10)
469 } else {
470 b = strconv.AppendInt(b, int64(-t.Year()), 10)
471 }
472
473 return string(b)
474 }
475
476
477 func (pl *pl) FmtDateMedium(t time.Time) string {
478
479 b := make([]byte, 0, 32)
480
481 b = strconv.AppendInt(b, int64(t.Day()), 10)
482 b = append(b, []byte{0x20}...)
483 b = append(b, pl.monthsAbbreviated[t.Month()]...)
484 b = append(b, []byte{0x20}...)
485
486 if t.Year() > 0 {
487 b = strconv.AppendInt(b, int64(t.Year()), 10)
488 } else {
489 b = strconv.AppendInt(b, int64(-t.Year()), 10)
490 }
491
492 return string(b)
493 }
494
495
496 func (pl *pl) FmtDateLong(t time.Time) string {
497
498 b := make([]byte, 0, 32)
499
500 b = strconv.AppendInt(b, int64(t.Day()), 10)
501 b = append(b, []byte{0x20}...)
502 b = append(b, pl.monthsWide[t.Month()]...)
503 b = append(b, []byte{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 (pl *pl) FmtDateFull(t time.Time) string {
516
517 b := make([]byte, 0, 32)
518
519 b = append(b, pl.daysWide[t.Weekday()]...)
520 b = append(b, []byte{0x2c, 0x20}...)
521 b = strconv.AppendInt(b, int64(t.Day()), 10)
522 b = append(b, []byte{0x20}...)
523 b = append(b, pl.monthsWide[t.Month()]...)
524 b = append(b, []byte{0x20}...)
525
526 if t.Year() > 0 {
527 b = strconv.AppendInt(b, int64(t.Year()), 10)
528 } else {
529 b = strconv.AppendInt(b, int64(-t.Year()), 10)
530 }
531
532 return string(b)
533 }
534
535
536 func (pl *pl) FmtTimeShort(t time.Time) string {
537
538 b := make([]byte, 0, 32)
539
540 if t.Hour() < 10 {
541 b = append(b, '0')
542 }
543
544 b = strconv.AppendInt(b, int64(t.Hour()), 10)
545 b = append(b, pl.timeSeparator...)
546
547 if t.Minute() < 10 {
548 b = append(b, '0')
549 }
550
551 b = strconv.AppendInt(b, int64(t.Minute()), 10)
552
553 return string(b)
554 }
555
556
557 func (pl *pl) FmtTimeMedium(t time.Time) string {
558
559 b := make([]byte, 0, 32)
560
561 if t.Hour() < 10 {
562 b = append(b, '0')
563 }
564
565 b = strconv.AppendInt(b, int64(t.Hour()), 10)
566 b = append(b, pl.timeSeparator...)
567
568 if t.Minute() < 10 {
569 b = append(b, '0')
570 }
571
572 b = strconv.AppendInt(b, int64(t.Minute()), 10)
573 b = append(b, pl.timeSeparator...)
574
575 if t.Second() < 10 {
576 b = append(b, '0')
577 }
578
579 b = strconv.AppendInt(b, int64(t.Second()), 10)
580
581 return string(b)
582 }
583
584
585 func (pl *pl) FmtTimeLong(t time.Time) string {
586
587 b := make([]byte, 0, 32)
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, pl.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, pl.timeSeparator...)
602
603 if t.Second() < 10 {
604 b = append(b, '0')
605 }
606
607 b = strconv.AppendInt(b, int64(t.Second()), 10)
608 b = append(b, []byte{0x20}...)
609
610 tz, _ := t.Zone()
611 b = append(b, tz...)
612
613 return string(b)
614 }
615
616
617 func (pl *pl) FmtTimeFull(t time.Time) string {
618
619 b := make([]byte, 0, 32)
620
621 if t.Hour() < 10 {
622 b = append(b, '0')
623 }
624
625 b = strconv.AppendInt(b, int64(t.Hour()), 10)
626 b = append(b, pl.timeSeparator...)
627
628 if t.Minute() < 10 {
629 b = append(b, '0')
630 }
631
632 b = strconv.AppendInt(b, int64(t.Minute()), 10)
633 b = append(b, pl.timeSeparator...)
634
635 if t.Second() < 10 {
636 b = append(b, '0')
637 }
638
639 b = strconv.AppendInt(b, int64(t.Second()), 10)
640 b = append(b, []byte{0x20}...)
641
642 tz, _ := t.Zone()
643
644 if btz, ok := pl.timezones[tz]; ok {
645 b = append(b, btz...)
646 } else {
647 b = append(b, tz...)
648 }
649
650 return string(b)
651 }
652
View as plain text