vai.go 16 KB

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