1 package da_DK
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 da_DK 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
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
46 func New() locales.Translator {
47 return &da_DK{
48 locale: "da_DK",
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", "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", "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", "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 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{"ACDT": "Centralaustralsk sommertid", "ACST": "Centralaustralsk normaltid", "ACWDT": "Vestlig centralaustralsk sommertid", "ACWST": "Vestlig centralaustralsk normaltid", "ADT": "Atlantic-sommertid", "AEDT": "Østaustralsk sommertid", "AEST": "Østaustralsk normaltid", "AKDT": "Alaska-sommertid", "AKST": "Alaska-normaltid", "ARST": "Argentinsk sommertid", "ART": "Argentinsk normaltid", "AST": "Atlantic-normaltid", "AWDT": "Vestaustralsk sommertid", "AWST": "Vestaustralsk normaltid", "BOT": "Boliviansk tid", "BT": "Bhutan-tid", "CAT": "Centralafrikansk tid", "CDT": "Central-sommertid", "CHADT": "Chatham-sommertid", "CHAST": "Chatham-normaltid", "CLST": "Chilensk sommertid", "CLT": "Chilensk normaltid", "COST": "Colombiansk sommertid", "COT": "Colombiansk normaltid", "CST": "Central-normaltid", "ChST": "Chamorro-tid", "EAT": "Østafrikansk tid", "ECT": "Ecuadoriansk tid", "EDT": "Eastern-sommertid", "EST": "Eastern-normaltid", "GFT": "Fransk Guyana-tid", "GMT": "GMT", "GST": "Golflandene-normaltid", "GYT": "Guyana-tid", "HADT": "Hawaii-Aleutian-sommertid", "HAST": "Hawaii-Aleutian-normaltid", "HAT": "Newfoundlandsk sommertid", "HECU": "Cubansk sommertid", "HEEG": "Østgrønlandsk sommertid", "HENOMX": "Nordvestmexicansk sommertid", "HEOG": "Vestgrønlandsk sommertid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "HEPMX": "Mexicansk Pacific-sommertid", "HKST": "Hongkong-sommertid", "HKT": "Hongkong-normaltid", "HNCU": "Cubansk normaltid", "HNEG": "Østgrønlandsk normaltid", "HNNOMX": "Nordvestmexicansk normaltid", "HNOG": "Vestgrønlandsk normaltid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "HNPMX": "Mexicansk Pacific-normaltid", "HNT": "Newfoundlandsk normaltid", "IST": "Indisk normaltid", "JDT": "Japansk sommertid", "JST": "Japansk normaltid", "LHDT": "Lord Howe-sommertid", "LHST": "Lord Howe-normaltid", "MDT": "Mountain-sommertid", "MESZ": "Centraleuropæisk sommertid", "MEZ": "Centraleuropæisk normaltid", "MST": "Mountain-normaltid", "MYT": "Malaysia-tid", "NZDT": "Newzealandsk sommertid", "NZST": "Newzealandsk normaltid", "OESZ": "Østeuropæisk sommertid", "OEZ": "Østeuropæisk normaltid", "PDT": "Pacific-sommertid", "PST": "Pacific-normaltid", "SAST": "Sydafrikansk tid", "SGT": "Singapore-tid", "SRT": "Surinam-tid", "TMST": "Turkmensk sommertid", "TMT": "Turkmensk normaltid", "UYST": "Uruguayansk sommertid", "UYT": "Uruguayansk normaltid", "VET": "Venezuelansk tid", "WARST": "Vestargentinsk sommertid", "WART": "Vestargentinsk normaltid", "WAST": "Vestafrikansk sommertid", "WAT": "Vestafrikansk normaltid", "WESZ": "Vesteuropæisk sommertid", "WEZ": "Vesteuropæisk normaltid", "WIB": "Vestindonesisk tid", "WIT": "Østindonesisk tid", "WITA": "Centralindonesisk tid", "∅∅∅": "Brasiliansk sommertid"},
77 }
78 }
79
80
81 func (da *da_DK) Locale() string {
82 return da.locale
83 }
84
85
86 func (da *da_DK) PluralsCardinal() []locales.PluralRule {
87 return da.pluralsCardinal
88 }
89
90
91 func (da *da_DK) PluralsOrdinal() []locales.PluralRule {
92 return da.pluralsOrdinal
93 }
94
95
96 func (da *da_DK) PluralsRange() []locales.PluralRule {
97 return da.pluralsRange
98 }
99
100
101 func (da *da_DK) 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
115 func (da *da_DK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116 return locales.PluralRuleOther
117 }
118
119
120 func (da *da_DK) 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
138 func (da *da_DK) MonthAbbreviated(month time.Month) string {
139 return da.monthsAbbreviated[month]
140 }
141
142
143 func (da *da_DK) MonthsAbbreviated() []string {
144 return da.monthsAbbreviated[1:]
145 }
146
147
148 func (da *da_DK) MonthNarrow(month time.Month) string {
149 return da.monthsNarrow[month]
150 }
151
152
153 func (da *da_DK) MonthsNarrow() []string {
154 return da.monthsNarrow[1:]
155 }
156
157
158 func (da *da_DK) MonthWide(month time.Month) string {
159 return da.monthsWide[month]
160 }
161
162
163 func (da *da_DK) MonthsWide() []string {
164 return da.monthsWide[1:]
165 }
166
167
168 func (da *da_DK) WeekdayAbbreviated(weekday time.Weekday) string {
169 return da.daysAbbreviated[weekday]
170 }
171
172
173 func (da *da_DK) WeekdaysAbbreviated() []string {
174 return da.daysAbbreviated
175 }
176
177
178 func (da *da_DK) WeekdayNarrow(weekday time.Weekday) string {
179 return da.daysNarrow[weekday]
180 }
181
182
183 func (da *da_DK) WeekdaysNarrow() []string {
184 return da.daysNarrow
185 }
186
187
188 func (da *da_DK) WeekdayShort(weekday time.Weekday) string {
189 return da.daysShort[weekday]
190 }
191
192
193 func (da *da_DK) WeekdaysShort() []string {
194 return da.daysShort
195 }
196
197
198 func (da *da_DK) WeekdayWide(weekday time.Weekday) string {
199 return da.daysWide[weekday]
200 }
201
202
203 func (da *da_DK) WeekdaysWide() []string {
204 return da.daysWide
205 }
206
207
208 func (da *da_DK) Decimal() string {
209 return da.decimal
210 }
211
212
213 func (da *da_DK) Group() string {
214 return da.group
215 }
216
217
218 func (da *da_DK) Minus() string {
219 return da.minus
220 }
221
222
223 func (da *da_DK) 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
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
264
265 func (da *da_DK) 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
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
297 func (da *da_DK) 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
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
354
355 func (da *da_DK) 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
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
419 func (da *da_DK) 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{0x2e}...)
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{0x2e}...)
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
448 func (da *da_DK) 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
467 func (da *da_DK) 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
486 func (da *da_DK) 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
508 func (da *da_DK) 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
529 func (da *da_DK) 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
557 func (da *da_DK) 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
589 func (da *da_DK) 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
View as plain text