da_GL.go 20 KB

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