twq.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. package twq
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type twq 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 'twq' locale
  39. func New() locales.Translator {
  40. return &twq{
  41. locale: "twq",
  42. pluralsCardinal: nil,
  43. pluralsOrdinal: nil,
  44. pluralsRange: nil,
  45. decimal: ".",
  46. group: " ",
  47. timeSeparator: ":",
  48. 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 ", "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 "},
  49. monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"},
  50. monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"},
  51. monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"},
  52. daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"},
  53. daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"},
  54. daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamiisa", "Alzuma", "Asibti"},
  55. periodsAbbreviated: []string{"Subbaahi", "Zaarikay b"},
  56. periodsWide: []string{"Subbaahi", "Zaarikay b"},
  57. erasAbbreviated: []string{"IJ", "IZ"},
  58. erasNarrow: []string{"", ""},
  59. erasWide: []string{"Isaa jine", "Isaa zamanoo"},
  60. timezones: map[string]string{"MYT": "MYT", "MST": "MST", "ADT": "ADT", "HAST": "HAST", "HKT": "HKT", "WITA": "WITA", "AKST": "AKST", "AWST": "AWST", "ACWST": "ACWST", "BT": "BT", "HKST": "HKST", "WART": "WART", "OESZ": "OESZ", "PDT": "PDT", "UYST": "UYST", "CHADT": "CHADT", "CLST": "CLST", "CAT": "CAT", "EDT": "EDT", "UYT": "UYT", "ACWDT": "ACWDT", "HADT": "HADT", "SAST": "SAST", "WIB": "WIB", "LHDT": "LHDT", "MEZ": "MEZ", "NZDT": "NZDT", "WAT": "WAT", "GMT": "GMT", "HNT": "HNT", "JST": "JST", "∅∅∅": "∅∅∅", "WIT": "WIT", "MESZ": "MESZ", "MDT": "MDT", "IST": "IST", "SRT": "SRT", "JDT": "JDT", "BOT": "BOT", "AEDT": "AEDT", "EAT": "EAT", "ARST": "ARST", "PST": "PST", "AWDT": "AWDT", "CST": "CST", "SGT": "SGT", "WARST": "WARST", "AKDT": "AKDT", "COT": "COT", "HAT": "HAT", "ACDT": "ACDT", "ART": "ART", "VET": "VET", "WEZ": "WEZ", "ECT": "ECT", "TMST": "TMST", "AEST": "AEST", "EST": "EST", "WAST": "WAST", "GFT": "GFT", "TMT": "TMT", "WESZ": "WESZ", "ChST": "ChST", "OEZ": "OEZ", "CDT": "CDT", "CLT": "CLT", "AST": "AST", "ACST": "ACST", "LHST": "LHST", "NZST": "NZST", "CHAST": "CHAST", "COST": "COST", "GYT": "GYT"},
  61. }
  62. }
  63. // Locale returns the current translators string locale
  64. func (twq *twq) Locale() string {
  65. return twq.locale
  66. }
  67. // PluralsCardinal returns the list of cardinal plural rules associated with 'twq'
  68. func (twq *twq) PluralsCardinal() []locales.PluralRule {
  69. return twq.pluralsCardinal
  70. }
  71. // PluralsOrdinal returns the list of ordinal plural rules associated with 'twq'
  72. func (twq *twq) PluralsOrdinal() []locales.PluralRule {
  73. return twq.pluralsOrdinal
  74. }
  75. // PluralsRange returns the list of range plural rules associated with 'twq'
  76. func (twq *twq) PluralsRange() []locales.PluralRule {
  77. return twq.pluralsRange
  78. }
  79. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'twq'
  80. func (twq *twq) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  81. return locales.PluralRuleUnknown
  82. }
  83. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'twq'
  84. func (twq *twq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. return locales.PluralRuleUnknown
  86. }
  87. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'twq'
  88. func (twq *twq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  89. return locales.PluralRuleUnknown
  90. }
  91. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  92. func (twq *twq) MonthAbbreviated(month time.Month) string {
  93. return twq.monthsAbbreviated[month]
  94. }
  95. // MonthsAbbreviated returns the locales abbreviated months
  96. func (twq *twq) MonthsAbbreviated() []string {
  97. return twq.monthsAbbreviated[1:]
  98. }
  99. // MonthNarrow returns the locales narrow month given the 'month' provided
  100. func (twq *twq) MonthNarrow(month time.Month) string {
  101. return twq.monthsNarrow[month]
  102. }
  103. // MonthsNarrow returns the locales narrow months
  104. func (twq *twq) MonthsNarrow() []string {
  105. return twq.monthsNarrow[1:]
  106. }
  107. // MonthWide returns the locales wide month given the 'month' provided
  108. func (twq *twq) MonthWide(month time.Month) string {
  109. return twq.monthsWide[month]
  110. }
  111. // MonthsWide returns the locales wide months
  112. func (twq *twq) MonthsWide() []string {
  113. return twq.monthsWide[1:]
  114. }
  115. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  116. func (twq *twq) WeekdayAbbreviated(weekday time.Weekday) string {
  117. return twq.daysAbbreviated[weekday]
  118. }
  119. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  120. func (twq *twq) WeekdaysAbbreviated() []string {
  121. return twq.daysAbbreviated
  122. }
  123. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  124. func (twq *twq) WeekdayNarrow(weekday time.Weekday) string {
  125. return twq.daysNarrow[weekday]
  126. }
  127. // WeekdaysNarrow returns the locales narrow weekdays
  128. func (twq *twq) WeekdaysNarrow() []string {
  129. return twq.daysNarrow
  130. }
  131. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  132. func (twq *twq) WeekdayShort(weekday time.Weekday) string {
  133. return twq.daysShort[weekday]
  134. }
  135. // WeekdaysShort returns the locales short weekdays
  136. func (twq *twq) WeekdaysShort() []string {
  137. return twq.daysShort
  138. }
  139. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  140. func (twq *twq) WeekdayWide(weekday time.Weekday) string {
  141. return twq.daysWide[weekday]
  142. }
  143. // WeekdaysWide returns the locales wide weekdays
  144. func (twq *twq) WeekdaysWide() []string {
  145. return twq.daysWide
  146. }
  147. // FmtNumber returns 'num' with digits/precision of 'v' for 'twq' and handles both Whole and Real numbers based on 'v'
  148. func (twq *twq) FmtNumber(num float64, v uint64) string {
  149. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  150. l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
  151. count := 0
  152. inWhole := v == 0
  153. b := make([]byte, 0, l)
  154. for i := len(s) - 1; i >= 0; i-- {
  155. if s[i] == '.' {
  156. b = append(b, twq.decimal[0])
  157. inWhole = true
  158. continue
  159. }
  160. if inWhole {
  161. if count == 3 {
  162. for j := len(twq.group) - 1; j >= 0; j-- {
  163. b = append(b, twq.group[j])
  164. }
  165. count = 1
  166. } else {
  167. count++
  168. }
  169. }
  170. b = append(b, s[i])
  171. }
  172. if num < 0 {
  173. b = append(b, twq.minus[0])
  174. }
  175. // reverse
  176. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  177. b[i], b[j] = b[j], b[i]
  178. }
  179. return string(b)
  180. }
  181. // FmtPercent returns 'num' with digits/precision of 'v' for 'twq' and handles both Whole and Real numbers based on 'v'
  182. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  183. func (twq *twq) FmtPercent(num float64, v uint64) string {
  184. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  185. l := len(s) + 1
  186. b := make([]byte, 0, l)
  187. for i := len(s) - 1; i >= 0; i-- {
  188. if s[i] == '.' {
  189. b = append(b, twq.decimal[0])
  190. continue
  191. }
  192. b = append(b, s[i])
  193. }
  194. if num < 0 {
  195. b = append(b, twq.minus[0])
  196. }
  197. // reverse
  198. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  199. b[i], b[j] = b[j], b[i]
  200. }
  201. b = append(b, twq.percent...)
  202. return string(b)
  203. }
  204. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'twq'
  205. func (twq *twq) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  206. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  207. symbol := twq.currencies[currency]
  208. l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3
  209. count := 0
  210. inWhole := v == 0
  211. b := make([]byte, 0, l)
  212. for i := len(s) - 1; i >= 0; i-- {
  213. if s[i] == '.' {
  214. b = append(b, twq.decimal[0])
  215. inWhole = true
  216. continue
  217. }
  218. if inWhole {
  219. if count == 3 {
  220. for j := len(twq.group) - 1; j >= 0; j-- {
  221. b = append(b, twq.group[j])
  222. }
  223. count = 1
  224. } else {
  225. count++
  226. }
  227. }
  228. b = append(b, s[i])
  229. }
  230. if num < 0 {
  231. b = append(b, twq.minus[0])
  232. }
  233. // reverse
  234. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  235. b[i], b[j] = b[j], b[i]
  236. }
  237. if int(v) < 2 {
  238. if v == 0 {
  239. b = append(b, twq.decimal...)
  240. }
  241. for i := 0; i < 2-int(v); i++ {
  242. b = append(b, '0')
  243. }
  244. }
  245. b = append(b, symbol...)
  246. return string(b)
  247. }
  248. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'twq'
  249. // in accounting notation.
  250. func (twq *twq) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  251. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  252. symbol := twq.currencies[currency]
  253. l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3
  254. count := 0
  255. inWhole := v == 0
  256. b := make([]byte, 0, l)
  257. for i := len(s) - 1; i >= 0; i-- {
  258. if s[i] == '.' {
  259. b = append(b, twq.decimal[0])
  260. inWhole = true
  261. continue
  262. }
  263. if inWhole {
  264. if count == 3 {
  265. for j := len(twq.group) - 1; j >= 0; j-- {
  266. b = append(b, twq.group[j])
  267. }
  268. count = 1
  269. } else {
  270. count++
  271. }
  272. }
  273. b = append(b, s[i])
  274. }
  275. if num < 0 {
  276. b = append(b, twq.minus[0])
  277. }
  278. // reverse
  279. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  280. b[i], b[j] = b[j], b[i]
  281. }
  282. if int(v) < 2 {
  283. if v == 0 {
  284. b = append(b, twq.decimal...)
  285. }
  286. for i := 0; i < 2-int(v); i++ {
  287. b = append(b, '0')
  288. }
  289. }
  290. if num < 0 {
  291. b = append(b, symbol...)
  292. } else {
  293. b = append(b, symbol...)
  294. }
  295. return string(b)
  296. }
  297. // FmtDateShort returns the short date representation of 't' for 'twq'
  298. func (twq *twq) FmtDateShort(t time.Time) string {
  299. b := make([]byte, 0, 32)
  300. b = strconv.AppendInt(b, int64(t.Day()), 10)
  301. b = append(b, []byte{0x2f}...)
  302. b = strconv.AppendInt(b, int64(t.Month()), 10)
  303. b = append(b, []byte{0x2f}...)
  304. b = strconv.AppendInt(b, int64(t.Year()), 10)
  305. return string(b)
  306. }
  307. // FmtDateMedium returns the medium date representation of 't' for 'twq'
  308. func (twq *twq) FmtDateMedium(t time.Time) string {
  309. b := make([]byte, 0, 32)
  310. b = strconv.AppendInt(b, int64(t.Day()), 10)
  311. b = append(b, []byte{0x20}...)
  312. b = append(b, twq.monthsAbbreviated[t.Month()]...)
  313. b = append(b, []byte{0x20}...)
  314. b = strconv.AppendInt(b, int64(t.Year()), 10)
  315. return string(b)
  316. }
  317. // FmtDateLong returns the long date representation of 't' for 'twq'
  318. func (twq *twq) FmtDateLong(t time.Time) string {
  319. b := make([]byte, 0, 32)
  320. b = strconv.AppendInt(b, int64(t.Day()), 10)
  321. b = append(b, []byte{0x20}...)
  322. b = append(b, twq.monthsWide[t.Month()]...)
  323. b = append(b, []byte{0x20}...)
  324. b = strconv.AppendInt(b, int64(t.Year()), 10)
  325. return string(b)
  326. }
  327. // FmtDateFull returns the full date representation of 't' for 'twq'
  328. func (twq *twq) FmtDateFull(t time.Time) string {
  329. b := make([]byte, 0, 32)
  330. b = append(b, twq.daysWide[t.Weekday()]...)
  331. b = append(b, []byte{0x20}...)
  332. b = strconv.AppendInt(b, int64(t.Day()), 10)
  333. b = append(b, []byte{0x20}...)
  334. b = append(b, twq.monthsWide[t.Month()]...)
  335. b = append(b, []byte{0x20}...)
  336. b = strconv.AppendInt(b, int64(t.Year()), 10)
  337. return string(b)
  338. }
  339. // FmtTimeShort returns the short time representation of 't' for 'twq'
  340. func (twq *twq) FmtTimeShort(t time.Time) string {
  341. b := make([]byte, 0, 32)
  342. if t.Hour() < 10 {
  343. b = append(b, '0')
  344. }
  345. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  346. b = append(b, twq.timeSeparator...)
  347. if t.Minute() < 10 {
  348. b = append(b, '0')
  349. }
  350. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  351. return string(b)
  352. }
  353. // FmtTimeMedium returns the medium time representation of 't' for 'twq'
  354. func (twq *twq) FmtTimeMedium(t time.Time) string {
  355. b := make([]byte, 0, 32)
  356. if t.Hour() < 10 {
  357. b = append(b, '0')
  358. }
  359. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  360. b = append(b, twq.timeSeparator...)
  361. if t.Minute() < 10 {
  362. b = append(b, '0')
  363. }
  364. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  365. b = append(b, twq.timeSeparator...)
  366. if t.Second() < 10 {
  367. b = append(b, '0')
  368. }
  369. b = strconv.AppendInt(b, int64(t.Second()), 10)
  370. return string(b)
  371. }
  372. // FmtTimeLong returns the long time representation of 't' for 'twq'
  373. func (twq *twq) FmtTimeLong(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, twq.timeSeparator...)
  380. if t.Minute() < 10 {
  381. b = append(b, '0')
  382. }
  383. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  384. b = append(b, twq.timeSeparator...)
  385. if t.Second() < 10 {
  386. b = append(b, '0')
  387. }
  388. b = strconv.AppendInt(b, int64(t.Second()), 10)
  389. b = append(b, []byte{0x20}...)
  390. tz, _ := t.Zone()
  391. b = append(b, tz...)
  392. return string(b)
  393. }
  394. // FmtTimeFull returns the full time representation of 't' for 'twq'
  395. func (twq *twq) FmtTimeFull(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, twq.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, twq.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. if btz, ok := twq.timezones[tz]; ok {
  414. b = append(b, btz...)
  415. } else {
  416. b = append(b, tz...)
  417. }
  418. return string(b)
  419. }