mt.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. package mt
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type mt 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. monthsAbbreviated []string
  23. monthsNarrow []string
  24. monthsWide []string
  25. daysAbbreviated []string
  26. daysNarrow []string
  27. daysShort []string
  28. daysWide []string
  29. periodsAbbreviated []string
  30. periodsNarrow []string
  31. periodsShort []string
  32. periodsWide []string
  33. erasAbbreviated []string
  34. erasNarrow []string
  35. erasWide []string
  36. timezones map[string]string
  37. }
  38. // New returns a new instance of translator for the 'mt' locale
  39. func New() locales.Translator {
  40. return &mt{
  41. locale: "mt",
  42. pluralsCardinal: []locales.PluralRule{2, 4, 5, 6},
  43. pluralsOrdinal: nil,
  44. pluralsRange: nil,
  45. decimal: ".",
  46. group: ",",
  47. minus: "-",
  48. percent: "%",
  49. perMille: "‰",
  50. timeSeparator: ":",
  51. inifinity: "∞",
  52. 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", "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", "€", "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"},
  53. monthsAbbreviated: []string{"", "Jan", "Fra", "Mar", "Apr", "Mej", "Ġun", "Lul", "Aww", "Set", "Ott", "Nov", "Diċ"},
  54. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Ġ", "L", "A", "S", "O", "N", "D"},
  55. monthsWide: []string{"", "Jannar", "Frar", "Marzu", "April", "Mejju", "Ġunju", "Lulju", "Awwissu", "Settembru", "Ottubru", "Novembru", "Diċembru"},
  56. daysAbbreviated: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"},
  57. daysNarrow: []string{"Ħ", "T", "T", "E", "Ħ", "Ġ", "S"},
  58. daysWide: []string{"Il-Ħadd", "It-Tnejn", "It-Tlieta", "L-Erbgħa", "Il-Ħamis", "Il-Ġimgħa", "Is-Sibt"},
  59. periodsAbbreviated: []string{"AM", "PM"},
  60. periodsWide: []string{"AM", "PM"},
  61. erasAbbreviated: []string{"QK", "WK"},
  62. erasNarrow: []string{"", ""},
  63. erasWide: []string{"Qabel Kristu", "Wara Kristu"},
  64. timezones: map[string]string{"CHADT": "CHADT", "ChST": "ChST", "AEDT": "AEDT", "LHST": "LHST", "JST": "JST", "WAST": "WAST", "MYT": "MYT", "AWDT": "AWDT", "HKT": "HKT", "AKST": "AKST", "AKDT": "AKDT", "PST": "PST", "WART": "WART", "BOT": "BOT", "EDT": "EDT", "JDT": "JDT", "HNT": "HNT", "WEZ": "WEZ", "WAT": "WAT", "CHAST": "CHAST", "ART": "ART", "COST": "COST", "MST": "MST", "WARST": "WARST", "BT": "BT", "ACST": "ACST", "WIB": "WIB", "MESZ": "Ħin Ċentrali Ewropew tas-Sajf", "PDT": "PDT", "OEZ": "OEZ", "ACWST": "ACWST", "HAT": "HAT", "SAST": "SAST", "SGT": "SGT", "TMST": "TMST", "CLST": "CLST", "OESZ": "OESZ", "HADT": "HADT", "EAT": "EAT", "ARST": "ARST", "AST": "AST", "GMT": "GMT", "ECT": "ECT", "GYT": "GYT", "UYT": "UYT", "NZDT": "NZDT", "ACWDT": "ACWDT", "∅∅∅": "∅∅∅", "VET": "VET", "TMT": "TMT", "UYST": "UYST", "ADT": "ADT", "WITA": "WITA", "HAST": "HAST", "WIT": "WIT", "CST": "CST", "NZST": "NZST", "GFT": "GFT", "CDT": "CDT", "CAT": "CAT", "HKST": "HKST", "CLT": "CLT", "IST": "IST", "SRT": "SRT", "AEST": "AEST", "EST": "EST", "ACDT": "ACDT", "MEZ": "Ħin Ċentrali Ewropew Standard", "COT": "COT", "MDT": "MDT", "LHDT": "LHDT", "WESZ": "WESZ", "AWST": "AWST"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (mt *mt) Locale() string {
  69. return mt.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'mt'
  72. func (mt *mt) PluralsCardinal() []locales.PluralRule {
  73. return mt.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'mt'
  76. func (mt *mt) PluralsOrdinal() []locales.PluralRule {
  77. return mt.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'mt'
  80. func (mt *mt) PluralsRange() []locales.PluralRule {
  81. return mt.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mt'
  84. func (mt *mt) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. n := math.Abs(num)
  86. nMod100 := math.Mod(n, 100)
  87. if n == 1 {
  88. return locales.PluralRuleOne
  89. } else if (n == 0) || (nMod100 >= 2 && nMod100 <= 10) {
  90. return locales.PluralRuleFew
  91. } else if nMod100 >= 11 && nMod100 <= 19 {
  92. return locales.PluralRuleMany
  93. }
  94. return locales.PluralRuleOther
  95. }
  96. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mt'
  97. func (mt *mt) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  98. return locales.PluralRuleUnknown
  99. }
  100. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mt'
  101. func (mt *mt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  102. return locales.PluralRuleUnknown
  103. }
  104. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  105. func (mt *mt) MonthAbbreviated(month time.Month) string {
  106. return mt.monthsAbbreviated[month]
  107. }
  108. // MonthsAbbreviated returns the locales abbreviated months
  109. func (mt *mt) MonthsAbbreviated() []string {
  110. return mt.monthsAbbreviated[1:]
  111. }
  112. // MonthNarrow returns the locales narrow month given the 'month' provided
  113. func (mt *mt) MonthNarrow(month time.Month) string {
  114. return mt.monthsNarrow[month]
  115. }
  116. // MonthsNarrow returns the locales narrow months
  117. func (mt *mt) MonthsNarrow() []string {
  118. return mt.monthsNarrow[1:]
  119. }
  120. // MonthWide returns the locales wide month given the 'month' provided
  121. func (mt *mt) MonthWide(month time.Month) string {
  122. return mt.monthsWide[month]
  123. }
  124. // MonthsWide returns the locales wide months
  125. func (mt *mt) MonthsWide() []string {
  126. return mt.monthsWide[1:]
  127. }
  128. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  129. func (mt *mt) WeekdayAbbreviated(weekday time.Weekday) string {
  130. return mt.daysAbbreviated[weekday]
  131. }
  132. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  133. func (mt *mt) WeekdaysAbbreviated() []string {
  134. return mt.daysAbbreviated
  135. }
  136. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  137. func (mt *mt) WeekdayNarrow(weekday time.Weekday) string {
  138. return mt.daysNarrow[weekday]
  139. }
  140. // WeekdaysNarrow returns the locales narrow weekdays
  141. func (mt *mt) WeekdaysNarrow() []string {
  142. return mt.daysNarrow
  143. }
  144. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  145. func (mt *mt) WeekdayShort(weekday time.Weekday) string {
  146. return mt.daysShort[weekday]
  147. }
  148. // WeekdaysShort returns the locales short weekdays
  149. func (mt *mt) WeekdaysShort() []string {
  150. return mt.daysShort
  151. }
  152. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  153. func (mt *mt) WeekdayWide(weekday time.Weekday) string {
  154. return mt.daysWide[weekday]
  155. }
  156. // WeekdaysWide returns the locales wide weekdays
  157. func (mt *mt) WeekdaysWide() []string {
  158. return mt.daysWide
  159. }
  160. // FmtNumber returns 'num' with digits/precision of 'v' for 'mt' and handles both Whole and Real numbers based on 'v'
  161. func (mt *mt) FmtNumber(num float64, v uint64) string {
  162. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  163. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  164. count := 0
  165. inWhole := v == 0
  166. b := make([]byte, 0, l)
  167. for i := len(s) - 1; i >= 0; i-- {
  168. if s[i] == '.' {
  169. b = append(b, mt.decimal[0])
  170. inWhole = true
  171. continue
  172. }
  173. if inWhole {
  174. if count == 3 {
  175. b = append(b, mt.group[0])
  176. count = 1
  177. } else {
  178. count++
  179. }
  180. }
  181. b = append(b, s[i])
  182. }
  183. if num < 0 {
  184. b = append(b, mt.minus[0])
  185. }
  186. // reverse
  187. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  188. b[i], b[j] = b[j], b[i]
  189. }
  190. return string(b)
  191. }
  192. // FmtPercent returns 'num' with digits/precision of 'v' for 'mt' and handles both Whole and Real numbers based on 'v'
  193. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  194. func (mt *mt) FmtPercent(num float64, v uint64) string {
  195. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  196. l := len(s) + 3
  197. b := make([]byte, 0, l)
  198. for i := len(s) - 1; i >= 0; i-- {
  199. if s[i] == '.' {
  200. b = append(b, mt.decimal[0])
  201. continue
  202. }
  203. b = append(b, s[i])
  204. }
  205. if num < 0 {
  206. b = append(b, mt.minus[0])
  207. }
  208. // reverse
  209. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  210. b[i], b[j] = b[j], b[i]
  211. }
  212. b = append(b, mt.percent...)
  213. return string(b)
  214. }
  215. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mt'
  216. func (mt *mt) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  217. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  218. symbol := mt.currencies[currency]
  219. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  220. count := 0
  221. inWhole := v == 0
  222. b := make([]byte, 0, l)
  223. for i := len(s) - 1; i >= 0; i-- {
  224. if s[i] == '.' {
  225. b = append(b, mt.decimal[0])
  226. inWhole = true
  227. continue
  228. }
  229. if inWhole {
  230. if count == 3 {
  231. b = append(b, mt.group[0])
  232. count = 1
  233. } else {
  234. count++
  235. }
  236. }
  237. b = append(b, s[i])
  238. }
  239. for j := len(symbol) - 1; j >= 0; j-- {
  240. b = append(b, symbol[j])
  241. }
  242. if num < 0 {
  243. b = append(b, mt.minus[0])
  244. }
  245. // reverse
  246. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  247. b[i], b[j] = b[j], b[i]
  248. }
  249. if int(v) < 2 {
  250. if v == 0 {
  251. b = append(b, mt.decimal...)
  252. }
  253. for i := 0; i < 2-int(v); i++ {
  254. b = append(b, '0')
  255. }
  256. }
  257. return string(b)
  258. }
  259. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mt'
  260. // in accounting notation.
  261. func (mt *mt) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  262. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  263. symbol := mt.currencies[currency]
  264. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  265. count := 0
  266. inWhole := v == 0
  267. b := make([]byte, 0, l)
  268. for i := len(s) - 1; i >= 0; i-- {
  269. if s[i] == '.' {
  270. b = append(b, mt.decimal[0])
  271. inWhole = true
  272. continue
  273. }
  274. if inWhole {
  275. if count == 3 {
  276. b = append(b, mt.group[0])
  277. count = 1
  278. } else {
  279. count++
  280. }
  281. }
  282. b = append(b, s[i])
  283. }
  284. if num < 0 {
  285. for j := len(symbol) - 1; j >= 0; j-- {
  286. b = append(b, symbol[j])
  287. }
  288. b = append(b, mt.minus[0])
  289. } else {
  290. for j := len(symbol) - 1; j >= 0; j-- {
  291. b = append(b, symbol[j])
  292. }
  293. }
  294. // reverse
  295. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  296. b[i], b[j] = b[j], b[i]
  297. }
  298. if int(v) < 2 {
  299. if v == 0 {
  300. b = append(b, mt.decimal...)
  301. }
  302. for i := 0; i < 2-int(v); i++ {
  303. b = append(b, '0')
  304. }
  305. }
  306. return string(b)
  307. }
  308. // FmtDateShort returns the short date representation of 't' for 'mt'
  309. func (mt *mt) FmtDateShort(t time.Time) string {
  310. b := make([]byte, 0, 32)
  311. if t.Day() < 10 {
  312. b = append(b, '0')
  313. }
  314. b = strconv.AppendInt(b, int64(t.Day()), 10)
  315. b = append(b, []byte{0x2f}...)
  316. if t.Month() < 10 {
  317. b = append(b, '0')
  318. }
  319. b = strconv.AppendInt(b, int64(t.Month()), 10)
  320. b = append(b, []byte{0x2f}...)
  321. b = strconv.AppendInt(b, int64(t.Year()), 10)
  322. return string(b)
  323. }
  324. // FmtDateMedium returns the medium date representation of 't' for 'mt'
  325. func (mt *mt) FmtDateMedium(t time.Time) string {
  326. b := make([]byte, 0, 32)
  327. if t.Day() < 10 {
  328. b = append(b, '0')
  329. }
  330. b = strconv.AppendInt(b, int64(t.Day()), 10)
  331. b = append(b, []byte{0x20}...)
  332. b = append(b, mt.monthsAbbreviated[t.Month()]...)
  333. b = append(b, []byte{0x20}...)
  334. b = strconv.AppendInt(b, int64(t.Year()), 10)
  335. return string(b)
  336. }
  337. // FmtDateLong returns the long date representation of 't' for 'mt'
  338. func (mt *mt) FmtDateLong(t time.Time) string {
  339. b := make([]byte, 0, 32)
  340. b = strconv.AppendInt(b, int64(t.Day()), 10)
  341. b = append(b, []byte{0x20, 0x74, 0x61}...)
  342. b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...)
  343. b = append(b, mt.monthsWide[t.Month()]...)
  344. b = append(b, []byte{0x20}...)
  345. b = strconv.AppendInt(b, int64(t.Year()), 10)
  346. return string(b)
  347. }
  348. // FmtDateFull returns the full date representation of 't' for 'mt'
  349. func (mt *mt) FmtDateFull(t time.Time) string {
  350. b := make([]byte, 0, 32)
  351. b = append(b, mt.daysWide[t.Weekday()]...)
  352. b = append(b, []byte{0x2c, 0x20}...)
  353. b = strconv.AppendInt(b, int64(t.Day()), 10)
  354. b = append(b, []byte{0x20, 0x74, 0x61}...)
  355. b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...)
  356. b = append(b, mt.monthsWide[t.Month()]...)
  357. b = append(b, []byte{0x20}...)
  358. b = strconv.AppendInt(b, int64(t.Year()), 10)
  359. return string(b)
  360. }
  361. // FmtTimeShort returns the short time representation of 't' for 'mt'
  362. func (mt *mt) FmtTimeShort(t time.Time) string {
  363. b := make([]byte, 0, 32)
  364. if t.Hour() < 10 {
  365. b = append(b, '0')
  366. }
  367. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  368. b = append(b, mt.timeSeparator...)
  369. if t.Minute() < 10 {
  370. b = append(b, '0')
  371. }
  372. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  373. return string(b)
  374. }
  375. // FmtTimeMedium returns the medium time representation of 't' for 'mt'
  376. func (mt *mt) FmtTimeMedium(t time.Time) string {
  377. b := make([]byte, 0, 32)
  378. if t.Hour() < 10 {
  379. b = append(b, '0')
  380. }
  381. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  382. b = append(b, mt.timeSeparator...)
  383. if t.Minute() < 10 {
  384. b = append(b, '0')
  385. }
  386. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  387. b = append(b, mt.timeSeparator...)
  388. if t.Second() < 10 {
  389. b = append(b, '0')
  390. }
  391. b = strconv.AppendInt(b, int64(t.Second()), 10)
  392. return string(b)
  393. }
  394. // FmtTimeLong returns the long time representation of 't' for 'mt'
  395. func (mt *mt) FmtTimeLong(t time.Time) string {
  396. b := make([]byte, 0, 32)
  397. if t.Hour() < 10 {
  398. b = append(b, '0')
  399. }
  400. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  401. b = append(b, mt.timeSeparator...)
  402. if t.Minute() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  406. b = append(b, mt.timeSeparator...)
  407. if t.Second() < 10 {
  408. b = append(b, '0')
  409. }
  410. b = strconv.AppendInt(b, int64(t.Second()), 10)
  411. b = append(b, []byte{0x20}...)
  412. tz, _ := t.Zone()
  413. b = append(b, tz...)
  414. return string(b)
  415. }
  416. // FmtTimeFull returns the full time representation of 't' for 'mt'
  417. func (mt *mt) FmtTimeFull(t time.Time) string {
  418. b := make([]byte, 0, 32)
  419. if t.Hour() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  423. b = append(b, mt.timeSeparator...)
  424. if t.Minute() < 10 {
  425. b = append(b, '0')
  426. }
  427. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  428. b = append(b, mt.timeSeparator...)
  429. if t.Second() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Second()), 10)
  433. b = append(b, []byte{0x20}...)
  434. tz, _ := t.Zone()
  435. if btz, ok := mt.timezones[tz]; ok {
  436. b = append(b, btz...)
  437. } else {
  438. b = append(b, tz...)
  439. }
  440. return string(b)
  441. }