1package nn
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/gohugoio/locales"
9	"github.com/gohugoio/locales/currency"
10)
11
12type nn 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	percentSuffix          string
22	perMille               string
23	timeSeparator          string
24	inifinity              string
25	currencies             []string // idx = enum of currency code
26	currencyPositiveSuffix 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// New returns a new instance of translator for the 'nn' locale
46func New() locales.Translator {
47	return &nn{
48		locale:                 "nn",
49		pluralsCardinal:        []locales.PluralRule{2, 6},
50		pluralsOrdinal:         nil,
51		pluralsRange:           nil,
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", "€", "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", "kr", "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", "Db", "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", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
60		percentSuffix:          " ",
61		currencyPositiveSuffix: " ",
62		currencyNegativeSuffix: " ",
63		monthsAbbreviated:      []string{"", "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des."},
64		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65		monthsWide:             []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"},
66		daysAbbreviated:        []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."},
67		daysNarrow:             []string{"S", "M", "T", "O", "T", "F", "L"},
68		daysShort:              []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."},
69		daysWide:               []string{"søndag", "måndag", "tysdag", "onsdag", "torsdag", "fredag", "laurdag"},
70		periodsAbbreviated:     []string{"f.m.", "e.m."},
71		periodsNarrow:          []string{"f.m.", "e.m."},
72		periodsWide:            []string{"formiddag", "ettermiddag"},
73		erasAbbreviated:        []string{"f.Kr.", "e.Kr."},
74		erasNarrow:             []string{"f.Kr.", "e.Kr."},
75		erasWide:               []string{"f.Kr.", "e.Kr."},
76		timezones:              map[string]string{"ACDT": "sentralaustralsk sommartid", "ACST": "sentralaustralsk standardtid", "ACWDT": "vest-sentralaustralsk sommartid", "ACWST": "vest-sentralaustralsk standardtid", "ADT": "sumartid for den nordamerikanske atlanterhavskysten", "AEDT": "austaustralsk sommartid", "AEST": "austaustralsk standardtid", "AKDT": "alaskisk sumartid", "AKST": "alaskisk normaltid", "ARST": "argentinsk sumartid", "ART": "argentinsk normaltid", "AST": "normaltid for den nordamerikanske atlanterhavskysten", "AWDT": "vestaustralsk sommartid", "AWST": "vestaustralsk standardtid", "BOT": "boliviansk tid", "BT": "bhutansk tid", "CAT": "sentralafrikansk tid", "CDT": "sumartid for sentrale Nord-Amerika", "CHADT": "sumartid for Chatham", "CHAST": "normaltid for Chatham", "CLST": "chilensk sumartid", "CLT": "chilensk normaltid", "COST": "kolombiansk sumartid", "COT": "kolombiansk normaltid", "CST": "normaltid for sentrale Nord-Amerika", "ChST": "tidssone for Chamorro", "EAT": "austafrikansk tid", "ECT": "ecuadoriansk tid", "EDT": "sumartid for den nordamerikansk austkysten", "EST": "normaltid for den nordamerikansk austkysten", "GFT": "tidssone for Fransk Guyana", "GMT": "Greenwich middeltid", "GST": "tidssone for Persiabukta", "GYT": "guyansk tid", "HADT": "sumartid for Hawaii og Aleutene", "HAST": "normaltid for Hawaii og Aleutene", "HAT": "sumartid for Newfoundland", "HECU": "kubansk sumartid", "HEEG": "austgrønlandsk sumartid", "HENOMX": "sumartid for nordvestlege Mexico", "HEOG": "vestgrønlandsk sumartid", "HEPM": "sumartid for Saint-Pierre-et-Miquelon", "HEPMX": "sumartid for den meksikanske stillehavskysten", "HKST": "hongkongkinesisk sumartid", "HKT": "hongkongkinesisk normaltid", "HNCU": "kubansk normaltid", "HNEG": "austgrønlandsk normaltid", "HNNOMX": "normaltid for nordvestlege Mexico", "HNOG": "vestgrønlandsk normaltid", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "HNPMX": "normaltid for den meksikanske stillehavskysten", "HNT": "normaltid for Newfoundland", "IST": "indisk tid", "JDT": "japansk sumartid", "JST": "japansk normaltid", "LHDT": "sumartid for Lord Howe-øya", "LHST": "normaltid for Lord Howe-øya", "MDT": "sumartid for Rocky Mountains (USA)", "MESZ": "sentraleuropeisk sommartid", "MEZ": "sentraleuropeisk standardtid", "MST": "normaltid for Rocky Mountains (USA)", "MYT": "malaysisk tid", "NZDT": "nyzealandsk sumartid", "NZST": "nyzealandsk normaltid", "OESZ": "austeuropeisk sommartid", "OEZ": "austeuropeisk standardtid", "PDT": "sumartid for den nordamerikanske stillehavskysten", "PST": "normaltid for den nordamerikanske stillehavskysten", "SAST": "sørafrikansk tid", "SGT": "singaporsk tid", "SRT": "surinamsk tid", "TMST": "turkmensk sumartid", "TMT": "turkmensk normaltid", "UYST": "uruguayansk sumartid", "UYT": "uruguayansk normaltid", "VET": "venezuelansk tid", "WARST": "vestargentinsk sumartid", "WART": "vestargentinsk normaltid", "WAST": "vestafrikansk sommartid", "WAT": "vestafrikansk standardtid", "WESZ": "vesteuropeisk sommartid", "WEZ": "vesteuropeisk standardtid", "WIB": "vestindonesisk tid", "WIT": "austindonesisk tid", "WITA": "sentralindonesisk tid", "∅∅∅": "peruansk sumartid"},
77	}
78}
79
80// Locale returns the current translators string locale
81func (nn *nn) Locale() string {
82	return nn.locale
83}
84
85// PluralsCardinal returns the list of cardinal plural rules associated with 'nn'
86func (nn *nn) PluralsCardinal() []locales.PluralRule {
87	return nn.pluralsCardinal
88}
89
90// PluralsOrdinal returns the list of ordinal plural rules associated with 'nn'
91func (nn *nn) PluralsOrdinal() []locales.PluralRule {
92	return nn.pluralsOrdinal
93}
94
95// PluralsRange returns the list of range plural rules associated with 'nn'
96func (nn *nn) PluralsRange() []locales.PluralRule {
97	return nn.pluralsRange
98}
99
100// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nn'
101func (nn *nn) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
102
103	n := math.Abs(num)
104
105	if n == 1 {
106		return locales.PluralRuleOne
107	}
108
109	return locales.PluralRuleOther
110}
111
112// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nn'
113func (nn *nn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
114	return locales.PluralRuleUnknown
115}
116
117// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nn'
118func (nn *nn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
119	return locales.PluralRuleUnknown
120}
121
122// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
123func (nn *nn) MonthAbbreviated(month time.Month) string {
124	return nn.monthsAbbreviated[month]
125}
126
127// MonthsAbbreviated returns the locales abbreviated months
128func (nn *nn) MonthsAbbreviated() []string {
129	return nn.monthsAbbreviated[1:]
130}
131
132// MonthNarrow returns the locales narrow month given the 'month' provided
133func (nn *nn) MonthNarrow(month time.Month) string {
134	return nn.monthsNarrow[month]
135}
136
137// MonthsNarrow returns the locales narrow months
138func (nn *nn) MonthsNarrow() []string {
139	return nn.monthsNarrow[1:]
140}
141
142// MonthWide returns the locales wide month given the 'month' provided
143func (nn *nn) MonthWide(month time.Month) string {
144	return nn.monthsWide[month]
145}
146
147// MonthsWide returns the locales wide months
148func (nn *nn) MonthsWide() []string {
149	return nn.monthsWide[1:]
150}
151
152// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
153func (nn *nn) WeekdayAbbreviated(weekday time.Weekday) string {
154	return nn.daysAbbreviated[weekday]
155}
156
157// WeekdaysAbbreviated returns the locales abbreviated weekdays
158func (nn *nn) WeekdaysAbbreviated() []string {
159	return nn.daysAbbreviated
160}
161
162// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
163func (nn *nn) WeekdayNarrow(weekday time.Weekday) string {
164	return nn.daysNarrow[weekday]
165}
166
167// WeekdaysNarrow returns the locales narrow weekdays
168func (nn *nn) WeekdaysNarrow() []string {
169	return nn.daysNarrow
170}
171
172// WeekdayShort returns the locales short weekday given the 'weekday' provided
173func (nn *nn) WeekdayShort(weekday time.Weekday) string {
174	return nn.daysShort[weekday]
175}
176
177// WeekdaysShort returns the locales short weekdays
178func (nn *nn) WeekdaysShort() []string {
179	return nn.daysShort
180}
181
182// WeekdayWide returns the locales wide weekday given the 'weekday' provided
183func (nn *nn) WeekdayWide(weekday time.Weekday) string {
184	return nn.daysWide[weekday]
185}
186
187// WeekdaysWide returns the locales wide weekdays
188func (nn *nn) WeekdaysWide() []string {
189	return nn.daysWide
190}
191
192// Decimal returns the decimal point of number
193func (nn *nn) Decimal() string {
194	return nn.decimal
195}
196
197// Group returns the group of number
198func (nn *nn) Group() string {
199	return nn.group
200}
201
202// Group returns the minus sign of number
203func (nn *nn) Minus() string {
204	return nn.minus
205}
206
207// FmtNumber returns 'num' with digits/precision of 'v' for 'nn' and handles both Whole and Real numbers based on 'v'
208func (nn *nn) FmtNumber(num float64, v uint64) string {
209
210	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211	l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3
212	count := 0
213	inWhole := v == 0
214	b := make([]byte, 0, l)
215
216	for i := len(s) - 1; i >= 0; i-- {
217
218		if s[i] == '.' {
219			b = append(b, nn.decimal[0])
220			inWhole = true
221			continue
222		}
223
224		if inWhole {
225			if count == 3 {
226				for j := len(nn.group) - 1; j >= 0; j-- {
227					b = append(b, nn.group[j])
228				}
229				count = 1
230			} else {
231				count++
232			}
233		}
234
235		b = append(b, s[i])
236	}
237
238	if num < 0 {
239		for j := len(nn.minus) - 1; j >= 0; j-- {
240			b = append(b, nn.minus[j])
241		}
242	}
243
244	// reverse
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// FmtPercent returns 'num' with digits/precision of 'v' for 'nn' and handles both Whole and Real numbers based on 'v'
253// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
254func (nn *nn) FmtPercent(num float64, v uint64) string {
255	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
256	l := len(s) + 7
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, nn.decimal[0])
263			continue
264		}
265
266		b = append(b, s[i])
267	}
268
269	if num < 0 {
270		for j := len(nn.minus) - 1; j >= 0; j-- {
271			b = append(b, nn.minus[j])
272		}
273	}
274
275	// reverse
276	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
277		b[i], b[j] = b[j], b[i]
278	}
279
280	b = append(b, nn.percentSuffix...)
281
282	b = append(b, nn.percent...)
283
284	return string(b)
285}
286
287// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nn'
288func (nn *nn) FmtCurrency(num float64, v uint64, currency currency.Type) string {
289
290	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
291	symbol := nn.currencies[currency]
292	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
293	count := 0
294	inWhole := v == 0
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, nn.decimal[0])
301			inWhole = true
302			continue
303		}
304
305		if inWhole {
306			if count == 3 {
307				for j := len(nn.group) - 1; j >= 0; j-- {
308					b = append(b, nn.group[j])
309				}
310				count = 1
311			} else {
312				count++
313			}
314		}
315
316		b = append(b, s[i])
317	}
318
319	if num < 0 {
320		for j := len(nn.minus) - 1; j >= 0; j-- {
321			b = append(b, nn.minus[j])
322		}
323	}
324
325	// reverse
326	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
327		b[i], b[j] = b[j], b[i]
328	}
329
330	if int(v) < 2 {
331
332		if v == 0 {
333			b = append(b, nn.decimal...)
334		}
335
336		for i := 0; i < 2-int(v); i++ {
337			b = append(b, '0')
338		}
339	}
340
341	b = append(b, nn.currencyPositiveSuffix...)
342
343	b = append(b, symbol...)
344
345	return string(b)
346}
347
348// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nn'
349// in accounting notation.
350func (nn *nn) FmtAccounting(num float64, v uint64, currency currency.Type) string {
351
352	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
353	symbol := nn.currencies[currency]
354	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
355	count := 0
356	inWhole := v == 0
357	b := make([]byte, 0, l)
358
359	for i := len(s) - 1; i >= 0; i-- {
360
361		if s[i] == '.' {
362			b = append(b, nn.decimal[0])
363			inWhole = true
364			continue
365		}
366
367		if inWhole {
368			if count == 3 {
369				for j := len(nn.group) - 1; j >= 0; j-- {
370					b = append(b, nn.group[j])
371				}
372				count = 1
373			} else {
374				count++
375			}
376		}
377
378		b = append(b, s[i])
379	}
380
381	if num < 0 {
382
383		for j := len(nn.minus) - 1; j >= 0; j-- {
384			b = append(b, nn.minus[j])
385		}
386
387	}
388
389	// reverse
390	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
391		b[i], b[j] = b[j], b[i]
392	}
393
394	if int(v) < 2 {
395
396		if v == 0 {
397			b = append(b, nn.decimal...)
398		}
399
400		for i := 0; i < 2-int(v); i++ {
401			b = append(b, '0')
402		}
403	}
404
405	if num < 0 {
406		b = append(b, nn.currencyNegativeSuffix...)
407		b = append(b, symbol...)
408	} else {
409
410		b = append(b, nn.currencyPositiveSuffix...)
411		b = append(b, symbol...)
412	}
413
414	return string(b)
415}
416
417// FmtDateShort returns the short date representation of 't' for 'nn'
418func (nn *nn) FmtDateShort(t time.Time) string {
419
420	b := make([]byte, 0, 32)
421
422	if t.Day() < 10 {
423		b = append(b, '0')
424	}
425
426	b = strconv.AppendInt(b, int64(t.Day()), 10)
427	b = append(b, []byte{0x2e}...)
428
429	if t.Month() < 10 {
430		b = append(b, '0')
431	}
432
433	b = strconv.AppendInt(b, int64(t.Month()), 10)
434
435	b = append(b, []byte{0x2e}...)
436
437	if t.Year() > 0 {
438		b = strconv.AppendInt(b, int64(t.Year()), 10)
439	} else {
440		b = strconv.AppendInt(b, int64(-t.Year()), 10)
441	}
442
443	return string(b)
444}
445
446// FmtDateMedium returns the medium date representation of 't' for 'nn'
447func (nn *nn) FmtDateMedium(t time.Time) string {
448
449	b := make([]byte, 0, 32)
450
451	b = strconv.AppendInt(b, int64(t.Day()), 10)
452	b = append(b, []byte{0x2e, 0x20}...)
453	b = append(b, nn.monthsAbbreviated[t.Month()]...)
454	b = append(b, []byte{0x20}...)
455
456	if t.Year() > 0 {
457		b = strconv.AppendInt(b, int64(t.Year()), 10)
458	} else {
459		b = strconv.AppendInt(b, int64(-t.Year()), 10)
460	}
461
462	return string(b)
463}
464
465// FmtDateLong returns the long date representation of 't' for 'nn'
466func (nn *nn) FmtDateLong(t time.Time) string {
467
468	b := make([]byte, 0, 32)
469
470	b = strconv.AppendInt(b, int64(t.Day()), 10)
471	b = append(b, []byte{0x2e, 0x20}...)
472	b = append(b, nn.monthsWide[t.Month()]...)
473	b = append(b, []byte{0x20}...)
474
475	if t.Year() > 0 {
476		b = strconv.AppendInt(b, int64(t.Year()), 10)
477	} else {
478		b = strconv.AppendInt(b, int64(-t.Year()), 10)
479	}
480
481	return string(b)
482}
483
484// FmtDateFull returns the full date representation of 't' for 'nn'
485func (nn *nn) FmtDateFull(t time.Time) string {
486
487	b := make([]byte, 0, 32)
488
489	b = append(b, nn.daysWide[t.Weekday()]...)
490	b = append(b, []byte{0x20}...)
491	b = strconv.AppendInt(b, int64(t.Day()), 10)
492	b = append(b, []byte{0x2e, 0x20}...)
493	b = append(b, nn.monthsWide[t.Month()]...)
494	b = append(b, []byte{0x20}...)
495
496	if t.Year() > 0 {
497		b = strconv.AppendInt(b, int64(t.Year()), 10)
498	} else {
499		b = strconv.AppendInt(b, int64(-t.Year()), 10)
500	}
501
502	return string(b)
503}
504
505// FmtTimeShort returns the short time representation of 't' for 'nn'
506func (nn *nn) FmtTimeShort(t time.Time) string {
507
508	b := make([]byte, 0, 32)
509
510	if t.Hour() < 10 {
511		b = append(b, '0')
512	}
513
514	b = strconv.AppendInt(b, int64(t.Hour()), 10)
515	b = append(b, nn.timeSeparator...)
516
517	if t.Minute() < 10 {
518		b = append(b, '0')
519	}
520
521	b = strconv.AppendInt(b, int64(t.Minute()), 10)
522
523	return string(b)
524}
525
526// FmtTimeMedium returns the medium time representation of 't' for 'nn'
527func (nn *nn) FmtTimeMedium(t time.Time) string {
528
529	b := make([]byte, 0, 32)
530
531	if t.Hour() < 10 {
532		b = append(b, '0')
533	}
534
535	b = strconv.AppendInt(b, int64(t.Hour()), 10)
536	b = append(b, nn.timeSeparator...)
537
538	if t.Minute() < 10 {
539		b = append(b, '0')
540	}
541
542	b = strconv.AppendInt(b, int64(t.Minute()), 10)
543	b = append(b, nn.timeSeparator...)
544
545	if t.Second() < 10 {
546		b = append(b, '0')
547	}
548
549	b = strconv.AppendInt(b, int64(t.Second()), 10)
550
551	return string(b)
552}
553
554// FmtTimeLong returns the long time representation of 't' for 'nn'
555func (nn *nn) FmtTimeLong(t time.Time) string {
556
557	b := make([]byte, 0, 32)
558
559	if t.Hour() < 10 {
560		b = append(b, '0')
561	}
562
563	b = strconv.AppendInt(b, int64(t.Hour()), 10)
564	b = append(b, nn.timeSeparator...)
565
566	if t.Minute() < 10 {
567		b = append(b, '0')
568	}
569
570	b = strconv.AppendInt(b, int64(t.Minute()), 10)
571	b = append(b, nn.timeSeparator...)
572
573	if t.Second() < 10 {
574		b = append(b, '0')
575	}
576
577	b = strconv.AppendInt(b, int64(t.Second()), 10)
578	b = append(b, []byte{0x20}...)
579
580	tz, _ := t.Zone()
581	b = append(b, tz...)
582
583	return string(b)
584}
585
586// FmtTimeFull returns the full time representation of 't' for 'nn'
587func (nn *nn) FmtTimeFull(t time.Time) string {
588
589	b := make([]byte, 0, 32)
590
591	b = append(b, []byte{0x6b, 0x6c}...)
592	b = append(b, []byte{0x2e, 0x20}...)
593
594	if t.Hour() < 10 {
595		b = append(b, '0')
596	}
597
598	b = strconv.AppendInt(b, int64(t.Hour()), 10)
599	b = append(b, nn.timeSeparator...)
600
601	if t.Minute() < 10 {
602		b = append(b, '0')
603	}
604
605	b = strconv.AppendInt(b, int64(t.Minute()), 10)
606	b = append(b, nn.timeSeparator...)
607
608	if t.Second() < 10 {
609		b = append(b, '0')
610	}
611
612	b = strconv.AppendInt(b, int64(t.Second()), 10)
613	b = append(b, []byte{0x20}...)
614
615	tz, _ := t.Zone()
616
617	if btz, ok := nn.timezones[tz]; ok {
618		b = append(b, btz...)
619	} else {
620		b = append(b, tz...)
621	}
622
623	return string(b)
624}
625