eu.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. package eu
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type eu 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. percentPrefix string
  19. perMille string
  20. timeSeparator string
  21. inifinity string
  22. currencies []string // idx = enum of currency code
  23. currencyPositiveSuffix string
  24. currencyNegativePrefix string
  25. currencyNegativeSuffix string
  26. monthsAbbreviated []string
  27. monthsNarrow []string
  28. monthsWide []string
  29. daysAbbreviated []string
  30. daysNarrow []string
  31. daysShort []string
  32. daysWide []string
  33. periodsAbbreviated []string
  34. periodsNarrow []string
  35. periodsShort []string
  36. periodsWide []string
  37. erasAbbreviated []string
  38. erasNarrow []string
  39. erasWide []string
  40. timezones map[string]string
  41. }
  42. // New returns a new instance of translator for the 'eu' locale
  43. func New() locales.Translator {
  44. return &eu{
  45. locale: "eu",
  46. pluralsCardinal: []locales.PluralRule{2, 6},
  47. pluralsOrdinal: []locales.PluralRule{6},
  48. pluralsRange: []locales.PluralRule{6},
  49. decimal: ",",
  50. group: ".",
  51. minus: "-",
  52. percent: "%",
  53. perMille: "‰",
  54. timeSeparator: ":",
  55. inifinity: "∞",
  56. currencies: []string{"ADP ", "AED", "AFA ", "AFN", "ALK ", "ALL", "AMD", "ANG", "AOA", "AOK ", "AON ", "AOR ", "ARA ", "ARL ", "ARM ", "ARP ", "ARS", "ATS ", "A$", "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 ", "BYR", "BZD", "CA$", "CDF", "CHE ", "CHF", "CHW ", "CLE ", "CLF ", "CLP", "CNX ", "CN¥", "COP", "COU ", "CRC", "CSD ", "CSK ", "CUC", "CUP", "CVE", "CYP ", "CZK", "DDM ", "DEM ", "DJF", "DKK", "DOP", "DZD", "ECS ", "ECV ", "EEK ", "EGP", "ERN", "ESA ", "ESB ", "₧", "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", "SUR ", "SVC ", "SYP", "SZL", "฿", "TJR ", "TJS", "TMM ", "TMT", "TND", "TOP", "TPE ", "TRL ", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK ", "UGS ", "UGX", "US$", "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 "},
  57. percentPrefix: " ",
  58. currencyPositiveSuffix: " ",
  59. currencyNegativePrefix: "(",
  60. currencyNegativeSuffix: " )",
  61. monthsAbbreviated: []string{"", "urt.", "ots.", "mar.", "api.", "mai.", "eka.", "uzt.", "abu.", "ira.", "urr.", "aza.", "abe."},
  62. monthsNarrow: []string{"", "U", "O", "M", "A", "M", "E", "U", "A", "I", "U", "A", "A"},
  63. monthsWide: []string{"", "urtarrilak", "otsailak", "martxoak", "apirilak", "maiatzak", "ekainak", "uztailak", "abuztuak", "irailak", "urriak", "azaroak", "abenduak"},
  64. daysAbbreviated: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."},
  65. daysNarrow: []string{"I", "A", "A", "A", "O", "O", "L"},
  66. daysShort: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."},
  67. daysWide: []string{"igandea", "astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larunbata"},
  68. periodsAbbreviated: []string{"AM", "PM"},
  69. periodsNarrow: []string{"g", "a"},
  70. periodsWide: []string{"AM", "PM"},
  71. erasAbbreviated: []string{"K.a.", "K.o."},
  72. erasNarrow: []string{"", ""},
  73. erasWide: []string{"K.a.", "K.o."},
  74. timezones: map[string]string{"WITA": "Indonesia erdialdeko ordua", "ACST": "Australia erdialdeko ordu estandarra", "JDT": "Japoniako udako ordua", "LHST": "Lord Howeko ordu estandarra", "UYST": "Uruguayko udako ordua", "COST": "Kolonbiako udako ordua", "ECT": "Ekuadorreko ordua", "HADT": "Hawaii-Aleutiar uharteetako udako ordua", "WIT": "Indonesia ekialdeko ordua", "SRT": "Surinamgo ordua", "UYT": "Uruguayko ordu estandarra", "VET": "Venezuelako ordua", "CAT": "Afrika erdialdeko ordua", "ADT": "Atlantikoko udako ordua", "WAT": "Afrika mendebaldeko ordu estandarra", "WARST": "Argentina mendebaldeko udako ordua", "CLT": "Txileko ordu estandarra", "EST": "Ipar Amerikako ekialdeko ordu estandarra", "AKST": "Alaskako ordu estandarra", "AWDT": "Australia mendebaldeko udako ordua", "CHAST": "Chathamgo ordu estandarra", "CLST": "Txileko udako ordua", "EDT": "Ipar Amerikako ekialdeko udako ordua", "ACDT": "Australia erdialdeko udako ordua", "NZDT": "Zeelanda Berriko udako ordua", "CHADT": "Chathamgo udako ordua", "MST": "Ipar Amerikako mendialdeko ordu estandarra", "∅∅∅": "Brasiliako udako ordua", "SGT": "Singapurreko ordu estandarra", "HKT": "Hong Kongo ordu estandarra", "AEST": "Australia ekialdeko ordu estandarra", "OESZ": "Europa ekialdeko udako ordua", "WEZ": "Europa mendebaldeko ordu estandarra", "WIB": "Indonesia mendebaldeko ordua", "HAT": "Ternuako udako ordua", "PDT": "Ipar Amerikako Pazifikoko udako ordua", "MYT": "Malaysiako ordua", "WESZ": "Europa mendebaldeko udako ordua", "AEDT": "Australia ekialdeko udako ordua", "ChST": "Chamorroko ordu estandarra", "AST": "Atlantikoko ordu estandarra", "GMT": "Greenwich meridianoko ordua", "AKDT": "Alaskako udako ordua", "CST": "Ipar Amerikako erdialdeko ordu estandarra", "CDT": "Ipar Amerikako erdialdeko udako ordua", "ACWST": "Australia erdi-mendebaldeko ordu estandarra", "ACWDT": "Australia erdi-mendebaldeko udako ordua", "HAST": "Hawaii-Aleutiar uharteetako ordu estandarra", "BT": "Bhutango ordua", "ART": "Argentinako ordu estandarra", "SAST": "Afrika hegoaldeko ordua", "HKST": "Hong Kongo udako ordua", "AWST": "Australia mendebaldeko ordu estandarra", "MDT": "Ipar Amerikako mendialdeko udako ordua", "WART": "Argentina mendebaldeko ordu estandarra", "IST": "Indiako ordua", "OEZ": "Europa ekialdeko ordu estandarra", "EAT": "Afrika ekialdeko ordua", "NZST": "Zeelanda Berriko ordu estandarra", "HNT": "Ternuako ordu estandarra", "GFT": "Guyana Frantseseko ordua", "TMST": "Turkmenistango udako ordua", "JST": "Japoniako ordu estandarra", "MEZ": "Europa erdialdeko ordu estandarra", "WAST": "Afrika mendebaldeko udako ordua", "GYT": "Guyanako ordua", "COT": "Kolonbiako ordu estandarra", "TMT": "Turkmenistango ordu estandarra", "PST": "Ipar Amerikako Pazifikoko ordu estandarra", "LHDT": "Lord Howeko udako ordua", "BOT": "Boliviako ordua", "ARST": "Argentinako udako ordua", "MESZ": "Europa erdialdeko udako ordua"},
  75. }
  76. }
  77. // Locale returns the current translators string locale
  78. func (eu *eu) Locale() string {
  79. return eu.locale
  80. }
  81. // PluralsCardinal returns the list of cardinal plural rules associated with 'eu'
  82. func (eu *eu) PluralsCardinal() []locales.PluralRule {
  83. return eu.pluralsCardinal
  84. }
  85. // PluralsOrdinal returns the list of ordinal plural rules associated with 'eu'
  86. func (eu *eu) PluralsOrdinal() []locales.PluralRule {
  87. return eu.pluralsOrdinal
  88. }
  89. // PluralsRange returns the list of range plural rules associated with 'eu'
  90. func (eu *eu) PluralsRange() []locales.PluralRule {
  91. return eu.pluralsRange
  92. }
  93. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'eu'
  94. func (eu *eu) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. n := math.Abs(num)
  96. if n == 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 'eu'
  102. func (eu *eu) 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 'eu'
  106. func (eu *eu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  107. return locales.PluralRuleOther
  108. }
  109. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  110. func (eu *eu) MonthAbbreviated(month time.Month) string {
  111. return eu.monthsAbbreviated[month]
  112. }
  113. // MonthsAbbreviated returns the locales abbreviated months
  114. func (eu *eu) MonthsAbbreviated() []string {
  115. return eu.monthsAbbreviated[1:]
  116. }
  117. // MonthNarrow returns the locales narrow month given the 'month' provided
  118. func (eu *eu) MonthNarrow(month time.Month) string {
  119. return eu.monthsNarrow[month]
  120. }
  121. // MonthsNarrow returns the locales narrow months
  122. func (eu *eu) MonthsNarrow() []string {
  123. return eu.monthsNarrow[1:]
  124. }
  125. // MonthWide returns the locales wide month given the 'month' provided
  126. func (eu *eu) MonthWide(month time.Month) string {
  127. return eu.monthsWide[month]
  128. }
  129. // MonthsWide returns the locales wide months
  130. func (eu *eu) MonthsWide() []string {
  131. return eu.monthsWide[1:]
  132. }
  133. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  134. func (eu *eu) WeekdayAbbreviated(weekday time.Weekday) string {
  135. return eu.daysAbbreviated[weekday]
  136. }
  137. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  138. func (eu *eu) WeekdaysAbbreviated() []string {
  139. return eu.daysAbbreviated
  140. }
  141. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  142. func (eu *eu) WeekdayNarrow(weekday time.Weekday) string {
  143. return eu.daysNarrow[weekday]
  144. }
  145. // WeekdaysNarrow returns the locales narrow weekdays
  146. func (eu *eu) WeekdaysNarrow() []string {
  147. return eu.daysNarrow
  148. }
  149. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  150. func (eu *eu) WeekdayShort(weekday time.Weekday) string {
  151. return eu.daysShort[weekday]
  152. }
  153. // WeekdaysShort returns the locales short weekdays
  154. func (eu *eu) WeekdaysShort() []string {
  155. return eu.daysShort
  156. }
  157. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  158. func (eu *eu) WeekdayWide(weekday time.Weekday) string {
  159. return eu.daysWide[weekday]
  160. }
  161. // WeekdaysWide returns the locales wide weekdays
  162. func (eu *eu) WeekdaysWide() []string {
  163. return eu.daysWide
  164. }
  165. // FmtNumber returns 'num' with digits/precision of 'v' for 'eu' and handles both Whole and Real numbers based on 'v'
  166. func (eu *eu) FmtNumber(num float64, v uint64) string {
  167. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  168. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  169. count := 0
  170. inWhole := v == 0
  171. b := make([]byte, 0, l)
  172. for i := len(s) - 1; i >= 0; i-- {
  173. if s[i] == '.' {
  174. b = append(b, eu.decimal[0])
  175. inWhole = true
  176. continue
  177. }
  178. if inWhole {
  179. if count == 3 {
  180. b = append(b, eu.group[0])
  181. count = 1
  182. } else {
  183. count++
  184. }
  185. }
  186. b = append(b, s[i])
  187. }
  188. if num < 0 {
  189. b = append(b, eu.minus[0])
  190. }
  191. // reverse
  192. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  193. b[i], b[j] = b[j], b[i]
  194. }
  195. return string(b)
  196. }
  197. // FmtPercent returns 'num' with digits/precision of 'v' for 'eu' and handles both Whole and Real numbers based on 'v'
  198. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  199. func (eu *eu) FmtPercent(num float64, v uint64) string {
  200. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  201. l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3
  202. count := 0
  203. inWhole := v == 0
  204. b := make([]byte, 0, l)
  205. for i := len(s) - 1; i >= 0; i-- {
  206. if s[i] == '.' {
  207. b = append(b, eu.decimal[0])
  208. inWhole = true
  209. continue
  210. }
  211. if inWhole {
  212. if count == 3 {
  213. b = append(b, eu.group[0])
  214. count = 1
  215. } else {
  216. count++
  217. }
  218. }
  219. b = append(b, s[i])
  220. }
  221. if num < 0 {
  222. b = append(b, eu.minus[0])
  223. }
  224. for j := len(eu.percentPrefix) - 1; j >= 0; j-- {
  225. b = append(b, eu.percentPrefix[j])
  226. }
  227. b = append(b, eu.percent[0])
  228. // reverse
  229. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  230. b[i], b[j] = b[j], b[i]
  231. }
  232. return string(b)
  233. }
  234. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'eu'
  235. func (eu *eu) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  236. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  237. symbol := eu.currencies[currency]
  238. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  239. count := 0
  240. inWhole := v == 0
  241. b := make([]byte, 0, l)
  242. for i := len(s) - 1; i >= 0; i-- {
  243. if s[i] == '.' {
  244. b = append(b, eu.decimal[0])
  245. inWhole = true
  246. continue
  247. }
  248. if inWhole {
  249. if count == 3 {
  250. b = append(b, eu.group[0])
  251. count = 1
  252. } else {
  253. count++
  254. }
  255. }
  256. b = append(b, s[i])
  257. }
  258. if num < 0 {
  259. b = append(b, eu.minus[0])
  260. }
  261. // reverse
  262. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  263. b[i], b[j] = b[j], b[i]
  264. }
  265. if int(v) < 2 {
  266. if v == 0 {
  267. b = append(b, eu.decimal...)
  268. }
  269. for i := 0; i < 2-int(v); i++ {
  270. b = append(b, '0')
  271. }
  272. }
  273. b = append(b, eu.currencyPositiveSuffix...)
  274. b = append(b, symbol...)
  275. return string(b)
  276. }
  277. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'eu'
  278. // in accounting notation.
  279. func (eu *eu) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  280. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  281. symbol := eu.currencies[currency]
  282. l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3
  283. count := 0
  284. inWhole := v == 0
  285. b := make([]byte, 0, l)
  286. for i := len(s) - 1; i >= 0; i-- {
  287. if s[i] == '.' {
  288. b = append(b, eu.decimal[0])
  289. inWhole = true
  290. continue
  291. }
  292. if inWhole {
  293. if count == 3 {
  294. b = append(b, eu.group[0])
  295. count = 1
  296. } else {
  297. count++
  298. }
  299. }
  300. b = append(b, s[i])
  301. }
  302. if num < 0 {
  303. b = append(b, eu.currencyNegativePrefix[0])
  304. }
  305. // reverse
  306. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  307. b[i], b[j] = b[j], b[i]
  308. }
  309. if int(v) < 2 {
  310. if v == 0 {
  311. b = append(b, eu.decimal...)
  312. }
  313. for i := 0; i < 2-int(v); i++ {
  314. b = append(b, '0')
  315. }
  316. }
  317. if num < 0 {
  318. b = append(b, eu.currencyNegativeSuffix...)
  319. b = append(b, symbol...)
  320. } else {
  321. b = append(b, eu.currencyPositiveSuffix...)
  322. b = append(b, symbol...)
  323. }
  324. return string(b)
  325. }
  326. // FmtDateShort returns the short date representation of 't' for 'eu'
  327. func (eu *eu) FmtDateShort(t time.Time) string {
  328. b := make([]byte, 0, 32)
  329. b = strconv.AppendInt(b, int64(t.Year()), 10)
  330. b = append(b, []byte{0x2f}...)
  331. if t.Month() < 10 {
  332. b = append(b, '0')
  333. }
  334. b = strconv.AppendInt(b, int64(t.Month()), 10)
  335. b = append(b, []byte{0x2f}...)
  336. if t.Day() < 10 {
  337. b = append(b, '0')
  338. }
  339. b = strconv.AppendInt(b, int64(t.Day()), 10)
  340. return string(b)
  341. }
  342. // FmtDateMedium returns the medium date representation of 't' for 'eu'
  343. func (eu *eu) FmtDateMedium(t time.Time) string {
  344. b := make([]byte, 0, 32)
  345. b = strconv.AppendInt(b, int64(t.Year()), 10)
  346. b = append(b, []byte{0x20}...)
  347. b = append(b, eu.monthsAbbreviated[t.Month()]...)
  348. b = append(b, []byte{0x20}...)
  349. b = strconv.AppendInt(b, int64(t.Day()), 10)
  350. return string(b)
  351. }
  352. // FmtDateLong returns the long date representation of 't' for 'eu'
  353. func (eu *eu) FmtDateLong(t time.Time) string {
  354. b := make([]byte, 0, 32)
  355. b = strconv.AppendInt(b, int64(t.Year()), 10)
  356. b = append(b, []byte{}...)
  357. b = append(b, []byte{0x27, 0x65, 0x27}...)
  358. b = append(b, []byte{0x27, 0x6b, 0x6f, 0x27, 0x20}...)
  359. b = append(b, eu.monthsWide[t.Month()]...)
  360. b = append(b, []byte{0x20}...)
  361. b = strconv.AppendInt(b, int64(t.Day()), 10)
  362. return string(b)
  363. }
  364. // FmtDateFull returns the full date representation of 't' for 'eu'
  365. func (eu *eu) FmtDateFull(t time.Time) string {
  366. b := make([]byte, 0, 32)
  367. b = strconv.AppendInt(b, int64(t.Year()), 10)
  368. b = append(b, []byte{}...)
  369. b = append(b, []byte{0x27, 0x65, 0x27}...)
  370. b = append(b, []byte{0x27, 0x6b, 0x6f, 0x27, 0x20}...)
  371. b = append(b, eu.monthsWide[t.Month()]...)
  372. b = append(b, []byte{0x20}...)
  373. b = strconv.AppendInt(b, int64(t.Day()), 10)
  374. b = append(b, []byte{0x2c, 0x20}...)
  375. b = append(b, eu.daysWide[t.Weekday()]...)
  376. return string(b)
  377. }
  378. // FmtTimeShort returns the short time representation of 't' for 'eu'
  379. func (eu *eu) FmtTimeShort(t time.Time) string {
  380. b := make([]byte, 0, 32)
  381. if t.Hour() < 10 {
  382. b = append(b, '0')
  383. }
  384. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  385. b = append(b, eu.timeSeparator...)
  386. if t.Minute() < 10 {
  387. b = append(b, '0')
  388. }
  389. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  390. return string(b)
  391. }
  392. // FmtTimeMedium returns the medium time representation of 't' for 'eu'
  393. func (eu *eu) FmtTimeMedium(t time.Time) string {
  394. b := make([]byte, 0, 32)
  395. if t.Hour() < 10 {
  396. b = append(b, '0')
  397. }
  398. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  399. b = append(b, eu.timeSeparator...)
  400. if t.Minute() < 10 {
  401. b = append(b, '0')
  402. }
  403. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  404. b = append(b, eu.timeSeparator...)
  405. if t.Second() < 10 {
  406. b = append(b, '0')
  407. }
  408. b = strconv.AppendInt(b, int64(t.Second()), 10)
  409. return string(b)
  410. }
  411. // FmtTimeLong returns the long time representation of 't' for 'eu'
  412. func (eu *eu) FmtTimeLong(t time.Time) string {
  413. b := make([]byte, 0, 32)
  414. if t.Hour() < 10 {
  415. b = append(b, '0')
  416. }
  417. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  418. b = append(b, eu.timeSeparator...)
  419. if t.Minute() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  423. b = append(b, eu.timeSeparator...)
  424. if t.Second() < 10 {
  425. b = append(b, '0')
  426. }
  427. b = strconv.AppendInt(b, int64(t.Second()), 10)
  428. b = append(b, []byte{0x20, 0x28}...)
  429. tz, _ := t.Zone()
  430. b = append(b, tz...)
  431. b = append(b, []byte{0x29}...)
  432. return string(b)
  433. }
  434. // FmtTimeFull returns the full time representation of 't' for 'eu'
  435. func (eu *eu) FmtTimeFull(t time.Time) string {
  436. b := make([]byte, 0, 32)
  437. if t.Hour() < 10 {
  438. b = append(b, '0')
  439. }
  440. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  441. b = append(b, eu.timeSeparator...)
  442. if t.Minute() < 10 {
  443. b = append(b, '0')
  444. }
  445. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  446. b = append(b, eu.timeSeparator...)
  447. if t.Second() < 10 {
  448. b = append(b, '0')
  449. }
  450. b = strconv.AppendInt(b, int64(t.Second()), 10)
  451. b = append(b, []byte{0x20, 0x28}...)
  452. tz, _ := t.Zone()
  453. if btz, ok := eu.timezones[tz]; ok {
  454. b = append(b, btz...)
  455. } else {
  456. b = append(b, tz...)
  457. }
  458. b = append(b, []byte{0x29}...)
  459. return string(b)
  460. }