ewo.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. package ewo
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ewo 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. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyPositiveSuffix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'ewo' locale
  41. func New() locales.Translator {
  42. return &ewo{
  43. locale: "ewo",
  44. pluralsCardinal: nil,
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: ",",
  48. group: " ",
  49. timeSeparator: ":",
  50. 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", "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", "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"},
  51. currencyPositiveSuffix: " ",
  52. currencyNegativeSuffix: " ",
  53. monthsAbbreviated: []string{"", "ngo", "ngb", "ngl", "ngn", "ngt", "ngs", "ngz", "ngm", "nge", "nga", "ngad", "ngab"},
  54. monthsNarrow: []string{"", "o", "b", "l", "n", "t", "s", "z", "m", "e", "a", "d", "b"},
  55. monthsWide: []string{"", "ngɔn osú", "ngɔn bɛ̌", "ngɔn lála", "ngɔn nyina", "ngɔn tána", "ngɔn saməna", "ngɔn zamgbála", "ngɔn mwom", "ngɔn ebulú", "ngɔn awóm", "ngɔn awóm ai dziá", "ngɔn awóm ai bɛ̌"},
  56. daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "fúl", "sér"},
  57. daysNarrow: []string{"s", "m", "s", "s", "s", "f", "s"},
  58. daysWide: []string{"sɔ́ndɔ", "mɔ́ndi", "sɔ́ndɔ məlú mə́bɛ̌", "sɔ́ndɔ məlú mə́lɛ́", "sɔ́ndɔ məlú mə́nyi", "fúladé", "séradé"},
  59. periodsAbbreviated: []string{"kíkíríg", "ngəgógəle"},
  60. periodsWide: []string{"kíkíríg", "ngəgógəle"},
  61. erasAbbreviated: []string{"oyk", "ayk"},
  62. erasNarrow: []string{"", ""},
  63. erasWide: []string{"osúsúa Yésus kiri", "ámvus Yésus Kirís"},
  64. timezones: map[string]string{"ART": "ART", "OEZ": "OEZ", "HEPMX": "HEPMX", "LHDT": "LHDT", "CLST": "CLST", "ARST": "ARST", "ChST": "ChST", "WIB": "WIB", "NZST": "NZST", "MEZ": "MEZ", "TMST": "TMST", "UYST": "UYST", "GFT": "GFT", "BT": "BT", "HEOG": "HEOG", "EDT": "EDT", "HNPM": "HNPM", "HADT": "HADT", "HECU": "HECU", "WEZ": "WEZ", "WAT": "WAT", "HAT": "HAT", "TMT": "TMT", "OESZ": "OESZ", "WIT": "WIT", "WESZ": "WESZ", "MYT": "MYT", "JDT": "JDT", "SGT": "SGT", "ACWST": "ACWST", "CLT": "CLT", "UYT": "UYT", "HNCU": "HNCU", "AKST": "AKST", "AKDT": "AKDT", "WARST": "WARST", "HEPM": "HEPM", "MDT": "MDT", "ACDT": "ACDT", "MST": "MST", "CST": "CST", "PDT": "PDT", "WITA": "WITA", "VET": "VET", "LHST": "LHST", "COST": "COST", "GYT": "GYT", "AWDT": "AWDT", "NZDT": "NZDT", "ECT": "ECT", "ACST": "ACST", "HKT": "HKT", "EAT": "EAT", "∅∅∅": "∅∅∅", "CHAST": "CHAST", "CDT": "CDT", "WART": "WART", "HKST": "HKST", "GMT": "GMT", "HNPMX": "HNPMX", "PST": "PST", "ADT": "ADT", "AEST": "AEST", "ACWDT": "ACWDT", "HNEG": "HNEG", "IST": "IST", "HENOMX": "HENOMX", "COT": "COT", "AEDT": "AEDT", "HEEG": "HEEG", "HNT": "HNT", "CAT": "CAT", "HAST": "HAST", "AST": "AST", "WAST": "WAST", "JST": "JST", "EST": "EST", "MESZ": "MESZ", "HNNOMX": "HNNOMX", "SRT": "SRT", "CHADT": "CHADT", "AWST": "AWST", "SAST": "SAST", "BOT": "BOT", "HNOG": "HNOG"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (ewo *ewo) Locale() string {
  69. return ewo.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'ewo'
  72. func (ewo *ewo) PluralsCardinal() []locales.PluralRule {
  73. return ewo.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ewo'
  76. func (ewo *ewo) PluralsOrdinal() []locales.PluralRule {
  77. return ewo.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'ewo'
  80. func (ewo *ewo) PluralsRange() []locales.PluralRule {
  81. return ewo.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ewo'
  84. func (ewo *ewo) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. return locales.PluralRuleUnknown
  86. }
  87. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ewo'
  88. func (ewo *ewo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  89. return locales.PluralRuleUnknown
  90. }
  91. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ewo'
  92. func (ewo *ewo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  93. return locales.PluralRuleUnknown
  94. }
  95. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  96. func (ewo *ewo) MonthAbbreviated(month time.Month) string {
  97. return ewo.monthsAbbreviated[month]
  98. }
  99. // MonthsAbbreviated returns the locales abbreviated months
  100. func (ewo *ewo) MonthsAbbreviated() []string {
  101. return ewo.monthsAbbreviated[1:]
  102. }
  103. // MonthNarrow returns the locales narrow month given the 'month' provided
  104. func (ewo *ewo) MonthNarrow(month time.Month) string {
  105. return ewo.monthsNarrow[month]
  106. }
  107. // MonthsNarrow returns the locales narrow months
  108. func (ewo *ewo) MonthsNarrow() []string {
  109. return ewo.monthsNarrow[1:]
  110. }
  111. // MonthWide returns the locales wide month given the 'month' provided
  112. func (ewo *ewo) MonthWide(month time.Month) string {
  113. return ewo.monthsWide[month]
  114. }
  115. // MonthsWide returns the locales wide months
  116. func (ewo *ewo) MonthsWide() []string {
  117. return ewo.monthsWide[1:]
  118. }
  119. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  120. func (ewo *ewo) WeekdayAbbreviated(weekday time.Weekday) string {
  121. return ewo.daysAbbreviated[weekday]
  122. }
  123. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  124. func (ewo *ewo) WeekdaysAbbreviated() []string {
  125. return ewo.daysAbbreviated
  126. }
  127. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  128. func (ewo *ewo) WeekdayNarrow(weekday time.Weekday) string {
  129. return ewo.daysNarrow[weekday]
  130. }
  131. // WeekdaysNarrow returns the locales narrow weekdays
  132. func (ewo *ewo) WeekdaysNarrow() []string {
  133. return ewo.daysNarrow
  134. }
  135. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  136. func (ewo *ewo) WeekdayShort(weekday time.Weekday) string {
  137. return ewo.daysShort[weekday]
  138. }
  139. // WeekdaysShort returns the locales short weekdays
  140. func (ewo *ewo) WeekdaysShort() []string {
  141. return ewo.daysShort
  142. }
  143. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  144. func (ewo *ewo) WeekdayWide(weekday time.Weekday) string {
  145. return ewo.daysWide[weekday]
  146. }
  147. // WeekdaysWide returns the locales wide weekdays
  148. func (ewo *ewo) WeekdaysWide() []string {
  149. return ewo.daysWide
  150. }
  151. // Decimal returns the decimal point of number
  152. func (ewo *ewo) Decimal() string {
  153. return ewo.decimal
  154. }
  155. // Group returns the group of number
  156. func (ewo *ewo) Group() string {
  157. return ewo.group
  158. }
  159. // Group returns the minus sign of number
  160. func (ewo *ewo) Minus() string {
  161. return ewo.minus
  162. }
  163. // FmtNumber returns 'num' with digits/precision of 'v' for 'ewo' and handles both Whole and Real numbers based on 'v'
  164. func (ewo *ewo) FmtNumber(num float64, v uint64) string {
  165. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  166. l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
  167. count := 0
  168. inWhole := v == 0
  169. b := make([]byte, 0, l)
  170. for i := len(s) - 1; i >= 0; i-- {
  171. if s[i] == '.' {
  172. b = append(b, ewo.decimal[0])
  173. inWhole = true
  174. continue
  175. }
  176. if inWhole {
  177. if count == 3 {
  178. for j := len(ewo.group) - 1; j >= 0; j-- {
  179. b = append(b, ewo.group[j])
  180. }
  181. count = 1
  182. } else {
  183. count++
  184. }
  185. }
  186. b = append(b, s[i])
  187. }
  188. if num < 0 {
  189. b = append(b, ewo.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 'ewo' 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 (ewo *ewo) FmtPercent(num float64, v uint64) string {
  200. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  201. l := len(s) + 1
  202. b := make([]byte, 0, l)
  203. for i := len(s) - 1; i >= 0; i-- {
  204. if s[i] == '.' {
  205. b = append(b, ewo.decimal[0])
  206. continue
  207. }
  208. b = append(b, s[i])
  209. }
  210. if num < 0 {
  211. b = append(b, ewo.minus[0])
  212. }
  213. // reverse
  214. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  215. b[i], b[j] = b[j], b[i]
  216. }
  217. b = append(b, ewo.percent...)
  218. return string(b)
  219. }
  220. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ewo'
  221. func (ewo *ewo) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  222. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  223. symbol := ewo.currencies[currency]
  224. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  225. count := 0
  226. inWhole := v == 0
  227. b := make([]byte, 0, l)
  228. for i := len(s) - 1; i >= 0; i-- {
  229. if s[i] == '.' {
  230. b = append(b, ewo.decimal[0])
  231. inWhole = true
  232. continue
  233. }
  234. if inWhole {
  235. if count == 3 {
  236. for j := len(ewo.group) - 1; j >= 0; j-- {
  237. b = append(b, ewo.group[j])
  238. }
  239. count = 1
  240. } else {
  241. count++
  242. }
  243. }
  244. b = append(b, s[i])
  245. }
  246. if num < 0 {
  247. b = append(b, ewo.minus[0])
  248. }
  249. // reverse
  250. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  251. b[i], b[j] = b[j], b[i]
  252. }
  253. if int(v) < 2 {
  254. if v == 0 {
  255. b = append(b, ewo.decimal...)
  256. }
  257. for i := 0; i < 2-int(v); i++ {
  258. b = append(b, '0')
  259. }
  260. }
  261. b = append(b, ewo.currencyPositiveSuffix...)
  262. b = append(b, symbol...)
  263. return string(b)
  264. }
  265. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ewo'
  266. // in accounting notation.
  267. func (ewo *ewo) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  268. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  269. symbol := ewo.currencies[currency]
  270. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  271. count := 0
  272. inWhole := v == 0
  273. b := make([]byte, 0, l)
  274. for i := len(s) - 1; i >= 0; i-- {
  275. if s[i] == '.' {
  276. b = append(b, ewo.decimal[0])
  277. inWhole = true
  278. continue
  279. }
  280. if inWhole {
  281. if count == 3 {
  282. for j := len(ewo.group) - 1; j >= 0; j-- {
  283. b = append(b, ewo.group[j])
  284. }
  285. count = 1
  286. } else {
  287. count++
  288. }
  289. }
  290. b = append(b, s[i])
  291. }
  292. if num < 0 {
  293. b = append(b, ewo.minus[0])
  294. }
  295. // reverse
  296. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  297. b[i], b[j] = b[j], b[i]
  298. }
  299. if int(v) < 2 {
  300. if v == 0 {
  301. b = append(b, ewo.decimal...)
  302. }
  303. for i := 0; i < 2-int(v); i++ {
  304. b = append(b, '0')
  305. }
  306. }
  307. if num < 0 {
  308. b = append(b, ewo.currencyNegativeSuffix...)
  309. b = append(b, symbol...)
  310. } else {
  311. b = append(b, ewo.currencyPositiveSuffix...)
  312. b = append(b, symbol...)
  313. }
  314. return string(b)
  315. }
  316. // FmtDateShort returns the short date representation of 't' for 'ewo'
  317. func (ewo *ewo) FmtDateShort(t time.Time) string {
  318. b := make([]byte, 0, 32)
  319. b = strconv.AppendInt(b, int64(t.Day()), 10)
  320. b = append(b, []byte{0x2f}...)
  321. b = strconv.AppendInt(b, int64(t.Month()), 10)
  322. b = append(b, []byte{0x2f}...)
  323. if t.Year() > 0 {
  324. b = strconv.AppendInt(b, int64(t.Year()), 10)
  325. } else {
  326. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  327. }
  328. return string(b)
  329. }
  330. // FmtDateMedium returns the medium date representation of 't' for 'ewo'
  331. func (ewo *ewo) FmtDateMedium(t time.Time) string {
  332. b := make([]byte, 0, 32)
  333. b = strconv.AppendInt(b, int64(t.Day()), 10)
  334. b = append(b, []byte{0x20}...)
  335. b = append(b, ewo.monthsAbbreviated[t.Month()]...)
  336. b = append(b, []byte{0x20}...)
  337. if t.Year() > 0 {
  338. b = strconv.AppendInt(b, int64(t.Year()), 10)
  339. } else {
  340. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  341. }
  342. return string(b)
  343. }
  344. // FmtDateLong returns the long date representation of 't' for 'ewo'
  345. func (ewo *ewo) FmtDateLong(t time.Time) string {
  346. b := make([]byte, 0, 32)
  347. b = strconv.AppendInt(b, int64(t.Day()), 10)
  348. b = append(b, []byte{0x20}...)
  349. b = append(b, ewo.monthsWide[t.Month()]...)
  350. b = append(b, []byte{0x20}...)
  351. if t.Year() > 0 {
  352. b = strconv.AppendInt(b, int64(t.Year()), 10)
  353. } else {
  354. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  355. }
  356. return string(b)
  357. }
  358. // FmtDateFull returns the full date representation of 't' for 'ewo'
  359. func (ewo *ewo) FmtDateFull(t time.Time) string {
  360. b := make([]byte, 0, 32)
  361. b = append(b, ewo.daysWide[t.Weekday()]...)
  362. b = append(b, []byte{0x20}...)
  363. b = strconv.AppendInt(b, int64(t.Day()), 10)
  364. b = append(b, []byte{0x20}...)
  365. b = append(b, ewo.monthsWide[t.Month()]...)
  366. b = append(b, []byte{0x20}...)
  367. if t.Year() > 0 {
  368. b = strconv.AppendInt(b, int64(t.Year()), 10)
  369. } else {
  370. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  371. }
  372. return string(b)
  373. }
  374. // FmtTimeShort returns the short time representation of 't' for 'ewo'
  375. func (ewo *ewo) FmtTimeShort(t time.Time) string {
  376. b := make([]byte, 0, 32)
  377. if t.Hour() < 10 {
  378. b = append(b, '0')
  379. }
  380. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  381. b = append(b, ewo.timeSeparator...)
  382. if t.Minute() < 10 {
  383. b = append(b, '0')
  384. }
  385. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  386. return string(b)
  387. }
  388. // FmtTimeMedium returns the medium time representation of 't' for 'ewo'
  389. func (ewo *ewo) FmtTimeMedium(t time.Time) string {
  390. b := make([]byte, 0, 32)
  391. if t.Hour() < 10 {
  392. b = append(b, '0')
  393. }
  394. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  395. b = append(b, ewo.timeSeparator...)
  396. if t.Minute() < 10 {
  397. b = append(b, '0')
  398. }
  399. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  400. b = append(b, ewo.timeSeparator...)
  401. if t.Second() < 10 {
  402. b = append(b, '0')
  403. }
  404. b = strconv.AppendInt(b, int64(t.Second()), 10)
  405. return string(b)
  406. }
  407. // FmtTimeLong returns the long time representation of 't' for 'ewo'
  408. func (ewo *ewo) FmtTimeLong(t time.Time) string {
  409. b := make([]byte, 0, 32)
  410. if t.Hour() < 10 {
  411. b = append(b, '0')
  412. }
  413. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  414. b = append(b, ewo.timeSeparator...)
  415. if t.Minute() < 10 {
  416. b = append(b, '0')
  417. }
  418. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  419. b = append(b, ewo.timeSeparator...)
  420. if t.Second() < 10 {
  421. b = append(b, '0')
  422. }
  423. b = strconv.AppendInt(b, int64(t.Second()), 10)
  424. b = append(b, []byte{0x20}...)
  425. tz, _ := t.Zone()
  426. b = append(b, tz...)
  427. return string(b)
  428. }
  429. // FmtTimeFull returns the full time representation of 't' for 'ewo'
  430. func (ewo *ewo) FmtTimeFull(t time.Time) string {
  431. b := make([]byte, 0, 32)
  432. if t.Hour() < 10 {
  433. b = append(b, '0')
  434. }
  435. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  436. b = append(b, ewo.timeSeparator...)
  437. if t.Minute() < 10 {
  438. b = append(b, '0')
  439. }
  440. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  441. b = append(b, ewo.timeSeparator...)
  442. if t.Second() < 10 {
  443. b = append(b, '0')
  444. }
  445. b = strconv.AppendInt(b, int64(t.Second()), 10)
  446. b = append(b, []byte{0x20}...)
  447. tz, _ := t.Zone()
  448. if btz, ok := ewo.timezones[tz]; ok {
  449. b = append(b, btz...)
  450. } else {
  451. b = append(b, tz...)
  452. }
  453. return string(b)
  454. }