mua.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. package mua
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type mua 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. currencyNegativePrefix 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 'mua' locale
  41. func New() locales.Translator {
  42. return &mua{
  43. locale: "mua",
  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. currencyNegativePrefix: "(",
  52. currencyNegativeSuffix: ")",
  53. monthsAbbreviated: []string{"", "FLO", "CLA", "CKI", "FMF", "MAD", "MBI", "MLI", "MAM", "FDE", "FMU", "FGW", "FYU"},
  54. monthsNarrow: []string{"", "O", "A", "I", "F", "D", "B", "L", "M", "E", "U", "W", "Y"},
  55. monthsWide: []string{"", "Fĩi Loo", "Cokcwaklaŋne", "Cokcwaklii", "Fĩi Marfoo", "Madǝǝuutǝbijaŋ", "Mamǝŋgwãafahbii", "Mamǝŋgwãalii", "Madǝmbii", "Fĩi Dǝɓlii", "Fĩi Mundaŋ", "Fĩi Gwahlle", "Fĩi Yuru"},
  56. daysAbbreviated: []string{"Cya", "Cla", "Czi", "Cko", "Cka", "Cga", "Cze"},
  57. daysNarrow: []string{"Y", "L", "Z", "O", "A", "G", "E"},
  58. daysWide: []string{"Com’yakke", "Comlaaɗii", "Comzyiiɗii", "Comkolle", "Comkaldǝɓlii", "Comgaisuu", "Comzyeɓsuu"},
  59. periodsAbbreviated: []string{"comme", "lilli"},
  60. periodsWide: []string{"comme", "lilli"},
  61. erasAbbreviated: []string{"KK", "PK"},
  62. erasNarrow: []string{"", ""},
  63. erasWide: []string{"KǝPel Kristu", "Pel Kristu"},
  64. timezones: map[string]string{"BOT": "BOT", "ACWDT": "ACWDT", "HEOG": "HEOG", "WARST": "WARST", "VET": "VET", "UYST": "UYST", "AWST": "AWST", "AEDT": "AEDT", "WAT": "WAT", "BT": "BT", "ACWST": "ACWST", "HNEG": "HNEG", "ART": "ART", "HEPMX": "HEPMX", "AKDT": "AKDT", "HKST": "HKST", "SRT": "SRT", "COT": "COT", "∅∅∅": "∅∅∅", "GYT": "GYT", "HECU": "HECU", "HAT": "HAT", "MDT": "MDT", "WIT": "WIT", "COST": "COST", "MESZ": "MESZ", "HADT": "HADT", "ADT": "ADT", "WIB": "WIB", "GFT": "GFT", "NZDT": "NZDT", "MEZ": "MEZ", "WART": "WART", "PST": "PST", "WEZ": "WEZ", "WESZ": "WESZ", "HEEG": "HEEG", "HKT": "HKT", "CLST": "CLST", "CAT": "CAT", "HNCU": "HNCU", "CST": "CST", "HNOG": "HNOG", "EST": "EST", "LHST": "LHST", "HNPM": "HNPM", "MST": "MST", "EAT": "EAT", "SAST": "SAST", "JST": "JST", "HEPM": "HEPM", "HENOMX": "HENOMX", "OESZ": "OESZ", "AEST": "AEST", "MYT": "MYT", "JDT": "JDT", "ECT": "ECT", "SGT": "SGT", "HNT": "HNT", "ARST": "ARST", "AWDT": "AWDT", "PDT": "PDT", "ACDT": "ACDT", "IST": "IST", "CLT": "CLT", "TMT": "TMT", "OEZ": "OEZ", "ChST": "ChST", "CHAST": "CHAST", "AST": "AST", "WAST": "WAST", "LHDT": "LHDT", "WITA": "WITA", "HNNOMX": "HNNOMX", "TMST": "TMST", "AKST": "AKST", "CHADT": "CHADT", "HNPMX": "HNPMX", "NZST": "NZST", "EDT": "EDT", "ACST": "ACST", "HAST": "HAST", "UYT": "UYT", "GMT": "GMT", "CDT": "CDT"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (mua *mua) Locale() string {
  69. return mua.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'mua'
  72. func (mua *mua) PluralsCardinal() []locales.PluralRule {
  73. return mua.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'mua'
  76. func (mua *mua) PluralsOrdinal() []locales.PluralRule {
  77. return mua.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'mua'
  80. func (mua *mua) PluralsRange() []locales.PluralRule {
  81. return mua.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mua'
  84. func (mua *mua) 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 'mua'
  88. func (mua *mua) 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 'mua'
  92. func (mua *mua) 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 (mua *mua) MonthAbbreviated(month time.Month) string {
  97. return mua.monthsAbbreviated[month]
  98. }
  99. // MonthsAbbreviated returns the locales abbreviated months
  100. func (mua *mua) MonthsAbbreviated() []string {
  101. return mua.monthsAbbreviated[1:]
  102. }
  103. // MonthNarrow returns the locales narrow month given the 'month' provided
  104. func (mua *mua) MonthNarrow(month time.Month) string {
  105. return mua.monthsNarrow[month]
  106. }
  107. // MonthsNarrow returns the locales narrow months
  108. func (mua *mua) MonthsNarrow() []string {
  109. return mua.monthsNarrow[1:]
  110. }
  111. // MonthWide returns the locales wide month given the 'month' provided
  112. func (mua *mua) MonthWide(month time.Month) string {
  113. return mua.monthsWide[month]
  114. }
  115. // MonthsWide returns the locales wide months
  116. func (mua *mua) MonthsWide() []string {
  117. return mua.monthsWide[1:]
  118. }
  119. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  120. func (mua *mua) WeekdayAbbreviated(weekday time.Weekday) string {
  121. return mua.daysAbbreviated[weekday]
  122. }
  123. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  124. func (mua *mua) WeekdaysAbbreviated() []string {
  125. return mua.daysAbbreviated
  126. }
  127. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  128. func (mua *mua) WeekdayNarrow(weekday time.Weekday) string {
  129. return mua.daysNarrow[weekday]
  130. }
  131. // WeekdaysNarrow returns the locales narrow weekdays
  132. func (mua *mua) WeekdaysNarrow() []string {
  133. return mua.daysNarrow
  134. }
  135. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  136. func (mua *mua) WeekdayShort(weekday time.Weekday) string {
  137. return mua.daysShort[weekday]
  138. }
  139. // WeekdaysShort returns the locales short weekdays
  140. func (mua *mua) WeekdaysShort() []string {
  141. return mua.daysShort
  142. }
  143. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  144. func (mua *mua) WeekdayWide(weekday time.Weekday) string {
  145. return mua.daysWide[weekday]
  146. }
  147. // WeekdaysWide returns the locales wide weekdays
  148. func (mua *mua) WeekdaysWide() []string {
  149. return mua.daysWide
  150. }
  151. // Decimal returns the decimal point of number
  152. func (mua *mua) Decimal() string {
  153. return mua.decimal
  154. }
  155. // Group returns the group of number
  156. func (mua *mua) Group() string {
  157. return mua.group
  158. }
  159. // Group returns the minus sign of number
  160. func (mua *mua) Minus() string {
  161. return mua.minus
  162. }
  163. // FmtNumber returns 'num' with digits/precision of 'v' for 'mua' and handles both Whole and Real numbers based on 'v'
  164. func (mua *mua) FmtNumber(num float64, v uint64) string {
  165. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  166. l := len(s) + 1 + 1*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, mua.decimal[0])
  173. inWhole = true
  174. continue
  175. }
  176. if inWhole {
  177. if count == 3 {
  178. b = append(b, mua.group[0])
  179. count = 1
  180. } else {
  181. count++
  182. }
  183. }
  184. b = append(b, s[i])
  185. }
  186. if num < 0 {
  187. b = append(b, mua.minus[0])
  188. }
  189. // reverse
  190. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  191. b[i], b[j] = b[j], b[i]
  192. }
  193. return string(b)
  194. }
  195. // FmtPercent returns 'num' with digits/precision of 'v' for 'mua' and handles both Whole and Real numbers based on 'v'
  196. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  197. func (mua *mua) FmtPercent(num float64, v uint64) string {
  198. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  199. l := len(s) + 1
  200. b := make([]byte, 0, l)
  201. for i := len(s) - 1; i >= 0; i-- {
  202. if s[i] == '.' {
  203. b = append(b, mua.decimal[0])
  204. continue
  205. }
  206. b = append(b, s[i])
  207. }
  208. if num < 0 {
  209. b = append(b, mua.minus[0])
  210. }
  211. // reverse
  212. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  213. b[i], b[j] = b[j], b[i]
  214. }
  215. b = append(b, mua.percent...)
  216. return string(b)
  217. }
  218. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mua'
  219. func (mua *mua) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  220. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  221. symbol := mua.currencies[currency]
  222. l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
  223. count := 0
  224. inWhole := v == 0
  225. b := make([]byte, 0, l)
  226. for i := len(s) - 1; i >= 0; i-- {
  227. if s[i] == '.' {
  228. b = append(b, mua.decimal[0])
  229. inWhole = true
  230. continue
  231. }
  232. if inWhole {
  233. if count == 3 {
  234. b = append(b, mua.group[0])
  235. count = 1
  236. } else {
  237. count++
  238. }
  239. }
  240. b = append(b, s[i])
  241. }
  242. for j := len(symbol) - 1; j >= 0; j-- {
  243. b = append(b, symbol[j])
  244. }
  245. if num < 0 {
  246. b = append(b, mua.minus[0])
  247. }
  248. // reverse
  249. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  250. b[i], b[j] = b[j], b[i]
  251. }
  252. if int(v) < 2 {
  253. if v == 0 {
  254. b = append(b, mua.decimal...)
  255. }
  256. for i := 0; i < 2-int(v); i++ {
  257. b = append(b, '0')
  258. }
  259. }
  260. return string(b)
  261. }
  262. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mua'
  263. // in accounting notation.
  264. func (mua *mua) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  265. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  266. symbol := mua.currencies[currency]
  267. l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
  268. count := 0
  269. inWhole := v == 0
  270. b := make([]byte, 0, l)
  271. for i := len(s) - 1; i >= 0; i-- {
  272. if s[i] == '.' {
  273. b = append(b, mua.decimal[0])
  274. inWhole = true
  275. continue
  276. }
  277. if inWhole {
  278. if count == 3 {
  279. b = append(b, mua.group[0])
  280. count = 1
  281. } else {
  282. count++
  283. }
  284. }
  285. b = append(b, s[i])
  286. }
  287. if num < 0 {
  288. for j := len(symbol) - 1; j >= 0; j-- {
  289. b = append(b, symbol[j])
  290. }
  291. b = append(b, mua.currencyNegativePrefix[0])
  292. } else {
  293. for j := len(symbol) - 1; j >= 0; j-- {
  294. b = append(b, symbol[j])
  295. }
  296. }
  297. // reverse
  298. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  299. b[i], b[j] = b[j], b[i]
  300. }
  301. if int(v) < 2 {
  302. if v == 0 {
  303. b = append(b, mua.decimal...)
  304. }
  305. for i := 0; i < 2-int(v); i++ {
  306. b = append(b, '0')
  307. }
  308. }
  309. if num < 0 {
  310. b = append(b, mua.currencyNegativeSuffix...)
  311. }
  312. return string(b)
  313. }
  314. // FmtDateShort returns the short date representation of 't' for 'mua'
  315. func (mua *mua) FmtDateShort(t time.Time) string {
  316. b := make([]byte, 0, 32)
  317. b = strconv.AppendInt(b, int64(t.Day()), 10)
  318. b = append(b, []byte{0x2f}...)
  319. b = strconv.AppendInt(b, int64(t.Month()), 10)
  320. b = append(b, []byte{0x2f}...)
  321. if t.Year() > 0 {
  322. b = strconv.AppendInt(b, int64(t.Year()), 10)
  323. } else {
  324. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  325. }
  326. return string(b)
  327. }
  328. // FmtDateMedium returns the medium date representation of 't' for 'mua'
  329. func (mua *mua) FmtDateMedium(t time.Time) string {
  330. b := make([]byte, 0, 32)
  331. b = strconv.AppendInt(b, int64(t.Day()), 10)
  332. b = append(b, []byte{0x20}...)
  333. b = append(b, mua.monthsAbbreviated[t.Month()]...)
  334. b = append(b, []byte{0x20}...)
  335. if t.Year() > 0 {
  336. b = strconv.AppendInt(b, int64(t.Year()), 10)
  337. } else {
  338. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  339. }
  340. return string(b)
  341. }
  342. // FmtDateLong returns the long date representation of 't' for 'mua'
  343. func (mua *mua) FmtDateLong(t time.Time) string {
  344. b := make([]byte, 0, 32)
  345. b = strconv.AppendInt(b, int64(t.Day()), 10)
  346. b = append(b, []byte{0x20}...)
  347. b = append(b, mua.monthsWide[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()), 10)
  353. }
  354. return string(b)
  355. }
  356. // FmtDateFull returns the full date representation of 't' for 'mua'
  357. func (mua *mua) FmtDateFull(t time.Time) string {
  358. b := make([]byte, 0, 32)
  359. b = append(b, mua.daysWide[t.Weekday()]...)
  360. b = append(b, []byte{0x20}...)
  361. b = strconv.AppendInt(b, int64(t.Day()), 10)
  362. b = append(b, []byte{0x20}...)
  363. b = append(b, mua.monthsWide[t.Month()]...)
  364. b = append(b, []byte{0x20}...)
  365. if t.Year() > 0 {
  366. b = strconv.AppendInt(b, int64(t.Year()), 10)
  367. } else {
  368. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  369. }
  370. return string(b)
  371. }
  372. // FmtTimeShort returns the short time representation of 't' for 'mua'
  373. func (mua *mua) FmtTimeShort(t time.Time) string {
  374. b := make([]byte, 0, 32)
  375. if t.Hour() < 10 {
  376. b = append(b, '0')
  377. }
  378. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  379. b = append(b, mua.timeSeparator...)
  380. if t.Minute() < 10 {
  381. b = append(b, '0')
  382. }
  383. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  384. return string(b)
  385. }
  386. // FmtTimeMedium returns the medium time representation of 't' for 'mua'
  387. func (mua *mua) FmtTimeMedium(t time.Time) string {
  388. b := make([]byte, 0, 32)
  389. if t.Hour() < 10 {
  390. b = append(b, '0')
  391. }
  392. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  393. b = append(b, mua.timeSeparator...)
  394. if t.Minute() < 10 {
  395. b = append(b, '0')
  396. }
  397. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  398. b = append(b, mua.timeSeparator...)
  399. if t.Second() < 10 {
  400. b = append(b, '0')
  401. }
  402. b = strconv.AppendInt(b, int64(t.Second()), 10)
  403. return string(b)
  404. }
  405. // FmtTimeLong returns the long time representation of 't' for 'mua'
  406. func (mua *mua) FmtTimeLong(t time.Time) string {
  407. b := make([]byte, 0, 32)
  408. if t.Hour() < 10 {
  409. b = append(b, '0')
  410. }
  411. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  412. b = append(b, mua.timeSeparator...)
  413. if t.Minute() < 10 {
  414. b = append(b, '0')
  415. }
  416. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  417. b = append(b, mua.timeSeparator...)
  418. if t.Second() < 10 {
  419. b = append(b, '0')
  420. }
  421. b = strconv.AppendInt(b, int64(t.Second()), 10)
  422. b = append(b, []byte{0x20}...)
  423. tz, _ := t.Zone()
  424. b = append(b, tz...)
  425. return string(b)
  426. }
  427. // FmtTimeFull returns the full time representation of 't' for 'mua'
  428. func (mua *mua) FmtTimeFull(t time.Time) string {
  429. b := make([]byte, 0, 32)
  430. if t.Hour() < 10 {
  431. b = append(b, '0')
  432. }
  433. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  434. b = append(b, mua.timeSeparator...)
  435. if t.Minute() < 10 {
  436. b = append(b, '0')
  437. }
  438. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  439. b = append(b, mua.timeSeparator...)
  440. if t.Second() < 10 {
  441. b = append(b, '0')
  442. }
  443. b = strconv.AppendInt(b, int64(t.Second()), 10)
  444. b = append(b, []byte{0x20}...)
  445. tz, _ := t.Zone()
  446. if btz, ok := mua.timezones[tz]; ok {
  447. b = append(b, btz...)
  448. } else {
  449. b = append(b, tz...)
  450. }
  451. return string(b)
  452. }