1package da
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/go-playground/locales"
9	"github.com/go-playground/locales/currency"
10)
11
12type da 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 'da' locale
46func New() locales.Translator {
47	return &da{
48		locale:                 "da",
49		pluralsCardinal:        []locales.PluralRule{2, 6},
50		pluralsOrdinal:         []locales.PluralRule{6},
51		pluralsRange:           []locales.PluralRule{2, 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", "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", "kr.", "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", "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", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "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"},
60		percentSuffix:          " ",
61		currencyPositiveSuffix: " ",
62		currencyNegativeSuffix: " ",
63		monthsAbbreviated:      []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."},
64		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65		monthsWide:             []string{"", "januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"},
66		daysAbbreviated:        []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."},
67		daysNarrow:             []string{"S", "M", "T", "O", "T", "F", "L"},
68		daysShort:              []string{"sø", "ma", "ti", "on", "to", "fr", "lø"},
69		daysWide:               []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"},
70		periodsAbbreviated:     []string{"AM", "PM"},
71		periodsNarrow:          []string{"a", "p"},
72		periodsWide:            []string{"AM", "PM"},
73		erasAbbreviated:        []string{"f.Kr.", "e.Kr."},
74		erasNarrow:             []string{"fKr", "eKr"},
75		erasWide:               []string{"f.Kr.", "e.Kr."},
76		timezones:              map[string]string{"UYST": "Uruguayansk sommertid", "HEPMX": "Mexicansk Pacific-sommertid", "AKST": "Alaska-normaltid", "ACST": "Centralaustralsk normaltid", "MEZ": "Centraleuropæisk normaltid", "MESZ": "Centraleuropæisk sommertid", "WARST": "Vestargentinsk sommertid", "LHDT": "Lord Howe-sommertid", "SAST": "Sydafrikansk tid", "MYT": "Malaysia-tid", "SGT": "Singapore-tid", "MST": "Macao-normaltid", "WIT": "Østindonesisk tid", "TMST": "Turkmensk sommertid", "HADT": "Hawaii-Aleutian-sommertid", "ChST": "Chamorro-tid", "HNCU": "Cubansk normaltid", "HNPMX": "Mexicansk Pacific-normaltid", "CST": "Central-normaltid", "WART": "Vestargentinsk normaltid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "CLST": "Chilensk sommertid", "HAST": "Hawaii-Aleutian-normaltid", "COST": "Colombiansk sommertid", "CHAST": "Chatham-normaltid", "PST": "Pacific-normaltid", "AEST": "Østaustralsk normaltid", "∅∅∅": "Azorerne-sommertid", "HNNOMX": "Nordvestmexicansk normaltid", "SRT": "Surinam-tid", "TMT": "Turkmensk normaltid", "WAT": "Vestafrikansk normaltid", "EDT": "Eastern-sommertid", "LHST": "Lord Howe-normaltid", "HNT": "Newfoundlandsk normaltid", "GYT": "Guyana-tid", "WEZ": "Vesteuropæisk normaltid", "ART": "Argentinsk normaltid", "WIB": "Vestindonesisk tid", "GFT": "Fransk Guyana-tid", "JST": "Japansk normaltid", "EAT": "Østafrikansk tid", "COT": "Colombiansk normaltid", "HEEG": "Østgrønlandsk sommertid", "HEOG": "Vestgrønlandsk sommertid", "CAT": "Centralafrikansk tid", "NZDT": "New Zealand-sommertid", "AEDT": "Østaustralsk sommertid", "ECT": "Ecuadoriansk tid", "HNEG": "Østgrønlandsk normaltid", "VET": "Venezuelansk tid", "OEZ": "Østeuropæisk normaltid", "AWDT": "Vestaustralsk sommertid", "AST": "Atlantic-normaltid", "HKST": "Hongkong-sommertid", "HAT": "Newfoundlandsk sommertid", "PDT": "Pacific-sommertid", "HNOG": "Vestgrønlandsk normaltid", "WAST": "Vestafrikansk sommertid", "EST": "Eastern-normaltid", "HENOMX": "Nordvestmexicansk sommertid", "MDT": "Macao-sommertid", "ARST": "Argentinsk sommertid", "WESZ": "Vesteuropæisk sommertid", "UYT": "Uruguayansk normaltid", "BOT": "Boliviansk tid", "JDT": "Japansk sommertid", "ACWST": "Vestlig centralaustralsk normaltid", "CDT": "Central-sommertid", "HKT": "Hongkong-normaltid", "IST": "Indien-normaltid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "HECU": "Cubansk sommertid", "WITA": "Centralindonesisk tid", "GMT": "GMT", "ADT": "Atlantic-sommertid", "ACWDT": "Vestlig centralaustralsk sommertid", "OESZ": "Østeuropæisk sommertid", "AWST": "Vestaustralsk normaltid", "BT": "Bhutan-tid", "NZST": "New Zealand-normaltid", "CLT": "Chilensk normaltid", "CHADT": "Chatham-sommertid", "AKDT": "Alaska-sommertid", "ACDT": "Centralaustralsk sommertid"},
77	}
78}
79
80// Locale returns the current translators string locale
81func (da *da) Locale() string {
82	return da.locale
83}
84
85// PluralsCardinal returns the list of cardinal plural rules associated with 'da'
86func (da *da) PluralsCardinal() []locales.PluralRule {
87	return da.pluralsCardinal
88}
89
90// PluralsOrdinal returns the list of ordinal plural rules associated with 'da'
91func (da *da) PluralsOrdinal() []locales.PluralRule {
92	return da.pluralsOrdinal
93}
94
95// PluralsRange returns the list of range plural rules associated with 'da'
96func (da *da) PluralsRange() []locales.PluralRule {
97	return da.pluralsRange
98}
99
100// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da'
101func (da *da) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
102
103	n := math.Abs(num)
104	i := int64(n)
105	t := locales.T(n, v)
106
107	if (n == 1) || (t != 0 && (i == 0 || i == 1)) {
108		return locales.PluralRuleOne
109	}
110
111	return locales.PluralRuleOther
112}
113
114// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'da'
115func (da *da) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116	return locales.PluralRuleOther
117}
118
119// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'da'
120func (da *da) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
121
122	start := da.CardinalPluralRule(num1, v1)
123	end := da.CardinalPluralRule(num2, v2)
124
125	if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
126		return locales.PluralRuleOne
127	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
128		return locales.PluralRuleOther
129	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
130		return locales.PluralRuleOne
131	}
132
133	return locales.PluralRuleOther
134
135}
136
137// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
138func (da *da) MonthAbbreviated(month time.Month) string {
139	return da.monthsAbbreviated[month]
140}
141
142// MonthsAbbreviated returns the locales abbreviated months
143func (da *da) MonthsAbbreviated() []string {
144	return da.monthsAbbreviated[1:]
145}
146
147// MonthNarrow returns the locales narrow month given the 'month' provided
148func (da *da) MonthNarrow(month time.Month) string {
149	return da.monthsNarrow[month]
150}
151
152// MonthsNarrow returns the locales narrow months
153func (da *da) MonthsNarrow() []string {
154	return da.monthsNarrow[1:]
155}
156
157// MonthWide returns the locales wide month given the 'month' provided
158func (da *da) MonthWide(month time.Month) string {
159	return da.monthsWide[month]
160}
161
162// MonthsWide returns the locales wide months
163func (da *da) MonthsWide() []string {
164	return da.monthsWide[1:]
165}
166
167// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
168func (da *da) WeekdayAbbreviated(weekday time.Weekday) string {
169	return da.daysAbbreviated[weekday]
170}
171
172// WeekdaysAbbreviated returns the locales abbreviated weekdays
173func (da *da) WeekdaysAbbreviated() []string {
174	return da.daysAbbreviated
175}
176
177// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
178func (da *da) WeekdayNarrow(weekday time.Weekday) string {
179	return da.daysNarrow[weekday]
180}
181
182// WeekdaysNarrow returns the locales narrow weekdays
183func (da *da) WeekdaysNarrow() []string {
184	return da.daysNarrow
185}
186
187// WeekdayShort returns the locales short weekday given the 'weekday' provided
188func (da *da) WeekdayShort(weekday time.Weekday) string {
189	return da.daysShort[weekday]
190}
191
192// WeekdaysShort returns the locales short weekdays
193func (da *da) WeekdaysShort() []string {
194	return da.daysShort
195}
196
197// WeekdayWide returns the locales wide weekday given the 'weekday' provided
198func (da *da) WeekdayWide(weekday time.Weekday) string {
199	return da.daysWide[weekday]
200}
201
202// WeekdaysWide returns the locales wide weekdays
203func (da *da) WeekdaysWide() []string {
204	return da.daysWide
205}
206
207// Decimal returns the decimal point of number
208func (da *da) Decimal() string {
209	return da.decimal
210}
211
212// Group returns the group of number
213func (da *da) Group() string {
214	return da.group
215}
216
217// Group returns the minus sign of number
218func (da *da) Minus() string {
219	return da.minus
220}
221
222// FmtNumber returns 'num' with digits/precision of 'v' for 'da' and handles both Whole and Real numbers based on 'v'
223func (da *da) FmtNumber(num float64, v uint64) string {
224
225	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
226	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
227	count := 0
228	inWhole := v == 0
229	b := make([]byte, 0, l)
230
231	for i := len(s) - 1; i >= 0; i-- {
232
233		if s[i] == '.' {
234			b = append(b, da.decimal[0])
235			inWhole = true
236			continue
237		}
238
239		if inWhole {
240			if count == 3 {
241				b = append(b, da.group[0])
242				count = 1
243			} else {
244				count++
245			}
246		}
247
248		b = append(b, s[i])
249	}
250
251	if num < 0 {
252		b = append(b, da.minus[0])
253	}
254
255	// reverse
256	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
257		b[i], b[j] = b[j], b[i]
258	}
259
260	return string(b)
261}
262
263// FmtPercent returns 'num' with digits/precision of 'v' for 'da' and handles both Whole and Real numbers based on 'v'
264// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
265func (da *da) FmtPercent(num float64, v uint64) string {
266	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
267	l := len(s) + 5
268	b := make([]byte, 0, l)
269
270	for i := len(s) - 1; i >= 0; i-- {
271
272		if s[i] == '.' {
273			b = append(b, da.decimal[0])
274			continue
275		}
276
277		b = append(b, s[i])
278	}
279
280	if num < 0 {
281		b = append(b, da.minus[0])
282	}
283
284	// reverse
285	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
286		b[i], b[j] = b[j], b[i]
287	}
288
289	b = append(b, da.percentSuffix...)
290
291	b = append(b, da.percent...)
292
293	return string(b)
294}
295
296// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'da'
297func (da *da) FmtCurrency(num float64, v uint64, currency currency.Type) string {
298
299	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
300	symbol := da.currencies[currency]
301	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
302	count := 0
303	inWhole := v == 0
304	b := make([]byte, 0, l)
305
306	for i := len(s) - 1; i >= 0; i-- {
307
308		if s[i] == '.' {
309			b = append(b, da.decimal[0])
310			inWhole = true
311			continue
312		}
313
314		if inWhole {
315			if count == 3 {
316				b = append(b, da.group[0])
317				count = 1
318			} else {
319				count++
320			}
321		}
322
323		b = append(b, s[i])
324	}
325
326	if num < 0 {
327		b = append(b, da.minus[0])
328	}
329
330	// reverse
331	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
332		b[i], b[j] = b[j], b[i]
333	}
334
335	if int(v) < 2 {
336
337		if v == 0 {
338			b = append(b, da.decimal...)
339		}
340
341		for i := 0; i < 2-int(v); i++ {
342			b = append(b, '0')
343		}
344	}
345
346	b = append(b, da.currencyPositiveSuffix...)
347
348	b = append(b, symbol...)
349
350	return string(b)
351}
352
353// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'da'
354// in accounting notation.
355func (da *da) FmtAccounting(num float64, v uint64, currency currency.Type) string {
356
357	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
358	symbol := da.currencies[currency]
359	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
360	count := 0
361	inWhole := v == 0
362	b := make([]byte, 0, l)
363
364	for i := len(s) - 1; i >= 0; i-- {
365
366		if s[i] == '.' {
367			b = append(b, da.decimal[0])
368			inWhole = true
369			continue
370		}
371
372		if inWhole {
373			if count == 3 {
374				b = append(b, da.group[0])
375				count = 1
376			} else {
377				count++
378			}
379		}
380
381		b = append(b, s[i])
382	}
383
384	if num < 0 {
385
386		b = append(b, da.minus[0])
387
388	}
389
390	// reverse
391	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
392		b[i], b[j] = b[j], b[i]
393	}
394
395	if int(v) < 2 {
396
397		if v == 0 {
398			b = append(b, da.decimal...)
399		}
400
401		for i := 0; i < 2-int(v); i++ {
402			b = append(b, '0')
403		}
404	}
405
406	if num < 0 {
407		b = append(b, da.currencyNegativeSuffix...)
408		b = append(b, symbol...)
409	} else {
410
411		b = append(b, da.currencyPositiveSuffix...)
412		b = append(b, symbol...)
413	}
414
415	return string(b)
416}
417
418// FmtDateShort returns the short date representation of 't' for 'da'
419func (da *da) FmtDateShort(t time.Time) string {
420
421	b := make([]byte, 0, 32)
422
423	if t.Day() < 10 {
424		b = append(b, '0')
425	}
426
427	b = strconv.AppendInt(b, int64(t.Day()), 10)
428	b = append(b, []byte{0x2f}...)
429
430	if t.Month() < 10 {
431		b = append(b, '0')
432	}
433
434	b = strconv.AppendInt(b, int64(t.Month()), 10)
435
436	b = append(b, []byte{0x2f}...)
437
438	if t.Year() > 0 {
439		b = strconv.AppendInt(b, int64(t.Year()), 10)
440	} else {
441		b = strconv.AppendInt(b, int64(-t.Year()), 10)
442	}
443
444	return string(b)
445}
446
447// FmtDateMedium returns the medium date representation of 't' for 'da'
448func (da *da) FmtDateMedium(t time.Time) string {
449
450	b := make([]byte, 0, 32)
451
452	b = strconv.AppendInt(b, int64(t.Day()), 10)
453	b = append(b, []byte{0x2e, 0x20}...)
454	b = append(b, da.monthsAbbreviated[t.Month()]...)
455	b = append(b, []byte{0x20}...)
456
457	if t.Year() > 0 {
458		b = strconv.AppendInt(b, int64(t.Year()), 10)
459	} else {
460		b = strconv.AppendInt(b, int64(-t.Year()), 10)
461	}
462
463	return string(b)
464}
465
466// FmtDateLong returns the long date representation of 't' for 'da'
467func (da *da) FmtDateLong(t time.Time) string {
468
469	b := make([]byte, 0, 32)
470
471	b = strconv.AppendInt(b, int64(t.Day()), 10)
472	b = append(b, []byte{0x2e, 0x20}...)
473	b = append(b, da.monthsWide[t.Month()]...)
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// FmtDateFull returns the full date representation of 't' for 'da'
486func (da *da) FmtDateFull(t time.Time) string {
487
488	b := make([]byte, 0, 32)
489
490	b = append(b, da.daysWide[t.Weekday()]...)
491	b = append(b, []byte{0x20, 0x64, 0x65, 0x6e}...)
492	b = append(b, []byte{0x20}...)
493	b = strconv.AppendInt(b, int64(t.Day()), 10)
494	b = append(b, []byte{0x2e, 0x20}...)
495	b = append(b, da.monthsWide[t.Month()]...)
496	b = append(b, []byte{0x20}...)
497
498	if t.Year() > 0 {
499		b = strconv.AppendInt(b, int64(t.Year()), 10)
500	} else {
501		b = strconv.AppendInt(b, int64(-t.Year()), 10)
502	}
503
504	return string(b)
505}
506
507// FmtTimeShort returns the short time representation of 't' for 'da'
508func (da *da) FmtTimeShort(t time.Time) string {
509
510	b := make([]byte, 0, 32)
511
512	if t.Hour() < 10 {
513		b = append(b, '0')
514	}
515
516	b = strconv.AppendInt(b, int64(t.Hour()), 10)
517	b = append(b, []byte{0x2e}...)
518
519	if t.Minute() < 10 {
520		b = append(b, '0')
521	}
522
523	b = strconv.AppendInt(b, int64(t.Minute()), 10)
524
525	return string(b)
526}
527
528// FmtTimeMedium returns the medium time representation of 't' for 'da'
529func (da *da) FmtTimeMedium(t time.Time) string {
530
531	b := make([]byte, 0, 32)
532
533	if t.Hour() < 10 {
534		b = append(b, '0')
535	}
536
537	b = strconv.AppendInt(b, int64(t.Hour()), 10)
538	b = append(b, []byte{0x2e}...)
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, []byte{0x2e}...)
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// FmtTimeLong returns the long time representation of 't' for 'da'
557func (da *da) FmtTimeLong(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, []byte{0x2e}...)
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, []byte{0x2e}...)
574
575	if t.Second() < 10 {
576		b = append(b, '0')
577	}
578
579	b = strconv.AppendInt(b, int64(t.Second()), 10)
580	b = append(b, []byte{0x20}...)
581
582	tz, _ := t.Zone()
583	b = append(b, tz...)
584
585	return string(b)
586}
587
588// FmtTimeFull returns the full time representation of 't' for 'da'
589func (da *da) FmtTimeFull(t time.Time) string {
590
591	b := make([]byte, 0, 32)
592
593	if t.Hour() < 10 {
594		b = append(b, '0')
595	}
596
597	b = strconv.AppendInt(b, int64(t.Hour()), 10)
598	b = append(b, []byte{0x2e}...)
599
600	if t.Minute() < 10 {
601		b = append(b, '0')
602	}
603
604	b = strconv.AppendInt(b, int64(t.Minute()), 10)
605	b = append(b, []byte{0x2e}...)
606
607	if t.Second() < 10 {
608		b = append(b, '0')
609	}
610
611	b = strconv.AppendInt(b, int64(t.Second()), 10)
612	b = append(b, []byte{0x20}...)
613
614	tz, _ := t.Zone()
615
616	if btz, ok := da.timezones[tz]; ok {
617		b = append(b, btz...)
618	} else {
619		b = append(b, tz...)
620	}
621
622	return string(b)
623}
624