lkt.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. package lkt
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type lkt 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. currencyPositivePrefix string
  23. currencyPositiveSuffix string
  24. currencyNegativePrefix string
  25. currencyNegativeSuffix string
  26. monthsAbbreviated []string
  27. monthsNarrow []string
  28. monthsWide []string
  29. daysAbbreviated []string
  30. daysNarrow []string
  31. daysShort []string
  32. daysWide []string
  33. periodsAbbreviated []string
  34. periodsNarrow []string
  35. periodsShort []string
  36. periodsWide []string
  37. erasAbbreviated []string
  38. erasNarrow []string
  39. erasWide []string
  40. timezones map[string]string
  41. }
  42. // New returns a new instance of translator for the 'lkt' locale
  43. func New() locales.Translator {
  44. return &lkt{
  45. locale: "lkt",
  46. pluralsCardinal: []locales.PluralRule{6},
  47. pluralsOrdinal: nil,
  48. pluralsRange: nil,
  49. decimal: ".",
  50. group: ",",
  51. minus: "-",
  52. percent: "%",
  53. perMille: "‰",
  54. timeSeparator: ":",
  55. inifinity: "∞",
  56. 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", "$", "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"},
  57. currencyPositivePrefix: " ",
  58. currencyPositiveSuffix: "K",
  59. currencyNegativePrefix: " ",
  60. currencyNegativeSuffix: "K",
  61. monthsWide: []string{"", "Wiótheȟika Wí", "Thiyóȟeyuŋka Wí", "Ištáwičhayazaŋ Wí", "Pȟežítȟo Wí", "Čhaŋwápetȟo Wí", "Wípazukȟa-wašté Wí", "Čhaŋpȟásapa Wí", "Wasútȟuŋ Wí", "Čhaŋwápeǧi Wí", "Čhaŋwápe-kasná Wí", "Waníyetu Wí", "Tȟahékapšuŋ Wí"},
  62. daysNarrow: []string{"A", "W", "N", "Y", "T", "Z", "O"},
  63. daysWide: []string{"Aŋpétuwakȟaŋ", "Aŋpétuwaŋži", "Aŋpétunuŋpa", "Aŋpétuyamni", "Aŋpétutopa", "Aŋpétuzaptaŋ", "Owáŋgyužažapi"},
  64. timezones: map[string]string{"AKST": "AKST", "ACWDT": "ACWDT", "MEZ": "MEZ", "HECU": "HECU", "CST": "CST", "BT": "BT", "BOT": "BOT", "MESZ": "MESZ", "OESZ": "OESZ", "HNPMX": "HNPMX", "GFT": "GFT", "HEPM": "HEPM", "CLT": "CLT", "GYT": "GYT", "TMT": "TMT", "TMST": "TMST", "ARST": "ARST", "GMT": "GMT", "WAST": "WAST", "EST": "EST", "HNPM": "HNPM", "HNNOMX": "HNNOMX", "CHAST": "CHAST", "CHADT": "CHADT", "AWDT": "AWDT", "AST": "AST", "NZDT": "NZDT", "EDT": "EDT", "UYT": "UYT", "PST": "PST", "WART": "WART", "VET": "VET", "AEST": "AEST", "MYT": "MYT", "ECT": "ECT", "HEEG": "HEEG", "LHDT": "LHDT", "WARST": "WARST", "SRT": "SRT", "OEZ": "OEZ", "COT": "COT", "CDT": "CDT", "JST": "JST", "ACST": "ACST", "HNEG": "HNEG", "ChST": "ChST", "SGT": "SGT", "MST": "MST", "HNCU": "HNCU", "AKDT": "AKDT", "AEDT": "AEDT", "HAST": "HAST", "∅∅∅": "∅∅∅", "JDT": "JDT", "ACDT": "ACDT", "HNT": "HNT", "HAT": "HAT", "HENOMX": "HENOMX", "CAT": "CAT", "UYST": "UYST", "SAST": "SAST", "WESZ": "WESZ", "HKT": "HKT", "LHST": "LHST", "ADT": "ADT", "IST": "IST", "WEZ": "WEZ", "WIB": "WIB", "NZST": "NZST", "HEOG": "HEOG", "COST": "COST", "AWST": "AWST", "HEPMX": "HEPMX", "HNOG": "HNOG", "WITA": "WITA", "WIT": "WIT", "HADT": "HADT", "EAT": "EAT", "CLST": "CLST", "PDT": "PDT", "ART": "ART", "WAT": "WAT", "ACWST": "ACWST", "HKST": "HKST", "MDT": "MDT"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (lkt *lkt) Locale() string {
  69. return lkt.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'lkt'
  72. func (lkt *lkt) PluralsCardinal() []locales.PluralRule {
  73. return lkt.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'lkt'
  76. func (lkt *lkt) PluralsOrdinal() []locales.PluralRule {
  77. return lkt.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'lkt'
  80. func (lkt *lkt) PluralsRange() []locales.PluralRule {
  81. return lkt.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lkt'
  84. func (lkt *lkt) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. return locales.PluralRuleOther
  86. }
  87. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lkt'
  88. func (lkt *lkt) 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 'lkt'
  92. func (lkt *lkt) 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 (lkt *lkt) MonthAbbreviated(month time.Month) string {
  97. return lkt.monthsAbbreviated[month]
  98. }
  99. // MonthsAbbreviated returns the locales abbreviated months
  100. func (lkt *lkt) MonthsAbbreviated() []string {
  101. return nil
  102. }
  103. // MonthNarrow returns the locales narrow month given the 'month' provided
  104. func (lkt *lkt) MonthNarrow(month time.Month) string {
  105. return lkt.monthsNarrow[month]
  106. }
  107. // MonthsNarrow returns the locales narrow months
  108. func (lkt *lkt) MonthsNarrow() []string {
  109. return nil
  110. }
  111. // MonthWide returns the locales wide month given the 'month' provided
  112. func (lkt *lkt) MonthWide(month time.Month) string {
  113. return lkt.monthsWide[month]
  114. }
  115. // MonthsWide returns the locales wide months
  116. func (lkt *lkt) MonthsWide() []string {
  117. return lkt.monthsWide[1:]
  118. }
  119. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  120. func (lkt *lkt) WeekdayAbbreviated(weekday time.Weekday) string {
  121. return lkt.daysAbbreviated[weekday]
  122. }
  123. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  124. func (lkt *lkt) WeekdaysAbbreviated() []string {
  125. return lkt.daysAbbreviated
  126. }
  127. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  128. func (lkt *lkt) WeekdayNarrow(weekday time.Weekday) string {
  129. return lkt.daysNarrow[weekday]
  130. }
  131. // WeekdaysNarrow returns the locales narrow weekdays
  132. func (lkt *lkt) WeekdaysNarrow() []string {
  133. return lkt.daysNarrow
  134. }
  135. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  136. func (lkt *lkt) WeekdayShort(weekday time.Weekday) string {
  137. return lkt.daysShort[weekday]
  138. }
  139. // WeekdaysShort returns the locales short weekdays
  140. func (lkt *lkt) WeekdaysShort() []string {
  141. return lkt.daysShort
  142. }
  143. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  144. func (lkt *lkt) WeekdayWide(weekday time.Weekday) string {
  145. return lkt.daysWide[weekday]
  146. }
  147. // WeekdaysWide returns the locales wide weekdays
  148. func (lkt *lkt) WeekdaysWide() []string {
  149. return lkt.daysWide
  150. }
  151. // Decimal returns the decimal point of number
  152. func (lkt *lkt) Decimal() string {
  153. return lkt.decimal
  154. }
  155. // Group returns the group of number
  156. func (lkt *lkt) Group() string {
  157. return lkt.group
  158. }
  159. // Group returns the minus sign of number
  160. func (lkt *lkt) Minus() string {
  161. return lkt.minus
  162. }
  163. // FmtNumber returns 'num' with digits/precision of 'v' for 'lkt' and handles both Whole and Real numbers based on 'v'
  164. func (lkt *lkt) FmtNumber(num float64, v uint64) string {
  165. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  166. }
  167. // FmtPercent returns 'num' with digits/precision of 'v' for 'lkt' and handles both Whole and Real numbers based on 'v'
  168. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  169. func (lkt *lkt) FmtPercent(num float64, v uint64) string {
  170. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  171. }
  172. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lkt'
  173. func (lkt *lkt) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  174. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  175. symbol := lkt.currencies[currency]
  176. l := len(s) + len(symbol) + 5
  177. b := make([]byte, 0, l)
  178. for i := len(s) - 1; i >= 0; i-- {
  179. if s[i] == '.' {
  180. b = append(b, lkt.decimal[0])
  181. continue
  182. }
  183. b = append(b, s[i])
  184. }
  185. for j := len(symbol) - 1; j >= 0; j-- {
  186. b = append(b, symbol[j])
  187. }
  188. for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- {
  189. b = append(b, lkt.currencyPositivePrefix[j])
  190. }
  191. if num < 0 {
  192. b = append(b, lkt.minus[0])
  193. }
  194. // reverse
  195. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  196. b[i], b[j] = b[j], b[i]
  197. }
  198. b = append(b, lkt.currencyPositiveSuffix...)
  199. return string(b)
  200. }
  201. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lkt'
  202. // in accounting notation.
  203. func (lkt *lkt) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. symbol := lkt.currencies[currency]
  206. l := len(s) + len(symbol) + 5
  207. b := make([]byte, 0, l)
  208. for i := len(s) - 1; i >= 0; i-- {
  209. if s[i] == '.' {
  210. b = append(b, lkt.decimal[0])
  211. continue
  212. }
  213. b = append(b, s[i])
  214. }
  215. if num < 0 {
  216. for j := len(symbol) - 1; j >= 0; j-- {
  217. b = append(b, symbol[j])
  218. }
  219. for j := len(lkt.currencyNegativePrefix) - 1; j >= 0; j-- {
  220. b = append(b, lkt.currencyNegativePrefix[j])
  221. }
  222. b = append(b, lkt.minus[0])
  223. } else {
  224. for j := len(symbol) - 1; j >= 0; j-- {
  225. b = append(b, symbol[j])
  226. }
  227. for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- {
  228. b = append(b, lkt.currencyPositivePrefix[j])
  229. }
  230. }
  231. // reverse
  232. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  233. b[i], b[j] = b[j], b[i]
  234. }
  235. if num < 0 {
  236. b = append(b, lkt.currencyNegativeSuffix...)
  237. } else {
  238. b = append(b, lkt.currencyPositiveSuffix...)
  239. }
  240. return string(b)
  241. }
  242. // FmtDateShort returns the short date representation of 't' for 'lkt'
  243. func (lkt *lkt) FmtDateShort(t time.Time) string {
  244. b := make([]byte, 0, 32)
  245. b = strconv.AppendInt(b, int64(t.Month()), 10)
  246. b = append(b, []byte{0x2f}...)
  247. b = strconv.AppendInt(b, int64(t.Day()), 10)
  248. b = append(b, []byte{0x2f}...)
  249. if t.Year() > 9 {
  250. b = append(b, strconv.Itoa(t.Year())[2:]...)
  251. } else {
  252. b = append(b, strconv.Itoa(t.Year())[1:]...)
  253. }
  254. return string(b)
  255. }
  256. // FmtDateMedium returns the medium date representation of 't' for 'lkt'
  257. func (lkt *lkt) FmtDateMedium(t time.Time) string {
  258. b := make([]byte, 0, 32)
  259. b = append(b, lkt.monthsAbbreviated[t.Month()]...)
  260. b = append(b, []byte{0x20}...)
  261. b = strconv.AppendInt(b, int64(t.Day()), 10)
  262. b = append(b, []byte{0x2c, 0x20}...)
  263. if t.Year() > 0 {
  264. b = strconv.AppendInt(b, int64(t.Year()), 10)
  265. } else {
  266. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  267. }
  268. return string(b)
  269. }
  270. // FmtDateLong returns the long date representation of 't' for 'lkt'
  271. func (lkt *lkt) FmtDateLong(t time.Time) string {
  272. b := make([]byte, 0, 32)
  273. b = append(b, lkt.monthsWide[t.Month()]...)
  274. b = append(b, []byte{0x20}...)
  275. b = strconv.AppendInt(b, int64(t.Day()), 10)
  276. b = append(b, []byte{0x2c, 0x20}...)
  277. if t.Year() > 0 {
  278. b = strconv.AppendInt(b, int64(t.Year()), 10)
  279. } else {
  280. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  281. }
  282. return string(b)
  283. }
  284. // FmtDateFull returns the full date representation of 't' for 'lkt'
  285. func (lkt *lkt) FmtDateFull(t time.Time) string {
  286. b := make([]byte, 0, 32)
  287. b = append(b, lkt.daysWide[t.Weekday()]...)
  288. b = append(b, []byte{0x2c, 0x20}...)
  289. b = append(b, lkt.monthsWide[t.Month()]...)
  290. b = append(b, []byte{0x20}...)
  291. b = strconv.AppendInt(b, int64(t.Day()), 10)
  292. b = append(b, []byte{0x2c, 0x20}...)
  293. if t.Year() > 0 {
  294. b = strconv.AppendInt(b, int64(t.Year()), 10)
  295. } else {
  296. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  297. }
  298. return string(b)
  299. }
  300. // FmtTimeShort returns the short time representation of 't' for 'lkt'
  301. func (lkt *lkt) FmtTimeShort(t time.Time) string {
  302. b := make([]byte, 0, 32)
  303. h := t.Hour()
  304. if h > 12 {
  305. h -= 12
  306. }
  307. b = strconv.AppendInt(b, int64(h), 10)
  308. b = append(b, lkt.timeSeparator...)
  309. if t.Minute() < 10 {
  310. b = append(b, '0')
  311. }
  312. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  313. b = append(b, []byte{0x20}...)
  314. if t.Hour() < 12 {
  315. b = append(b, lkt.periodsAbbreviated[0]...)
  316. } else {
  317. b = append(b, lkt.periodsAbbreviated[1]...)
  318. }
  319. return string(b)
  320. }
  321. // FmtTimeMedium returns the medium time representation of 't' for 'lkt'
  322. func (lkt *lkt) FmtTimeMedium(t time.Time) string {
  323. b := make([]byte, 0, 32)
  324. h := t.Hour()
  325. if h > 12 {
  326. h -= 12
  327. }
  328. b = strconv.AppendInt(b, int64(h), 10)
  329. b = append(b, lkt.timeSeparator...)
  330. if t.Minute() < 10 {
  331. b = append(b, '0')
  332. }
  333. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  334. b = append(b, lkt.timeSeparator...)
  335. if t.Second() < 10 {
  336. b = append(b, '0')
  337. }
  338. b = strconv.AppendInt(b, int64(t.Second()), 10)
  339. b = append(b, []byte{0x20}...)
  340. if t.Hour() < 12 {
  341. b = append(b, lkt.periodsAbbreviated[0]...)
  342. } else {
  343. b = append(b, lkt.periodsAbbreviated[1]...)
  344. }
  345. return string(b)
  346. }
  347. // FmtTimeLong returns the long time representation of 't' for 'lkt'
  348. func (lkt *lkt) FmtTimeLong(t time.Time) string {
  349. b := make([]byte, 0, 32)
  350. h := t.Hour()
  351. if h > 12 {
  352. h -= 12
  353. }
  354. b = strconv.AppendInt(b, int64(h), 10)
  355. b = append(b, lkt.timeSeparator...)
  356. if t.Minute() < 10 {
  357. b = append(b, '0')
  358. }
  359. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  360. b = append(b, lkt.timeSeparator...)
  361. if t.Second() < 10 {
  362. b = append(b, '0')
  363. }
  364. b = strconv.AppendInt(b, int64(t.Second()), 10)
  365. b = append(b, []byte{0x20}...)
  366. if t.Hour() < 12 {
  367. b = append(b, lkt.periodsAbbreviated[0]...)
  368. } else {
  369. b = append(b, lkt.periodsAbbreviated[1]...)
  370. }
  371. b = append(b, []byte{0x20}...)
  372. tz, _ := t.Zone()
  373. b = append(b, tz...)
  374. return string(b)
  375. }
  376. // FmtTimeFull returns the full time representation of 't' for 'lkt'
  377. func (lkt *lkt) FmtTimeFull(t time.Time) string {
  378. b := make([]byte, 0, 32)
  379. h := t.Hour()
  380. if h > 12 {
  381. h -= 12
  382. }
  383. b = strconv.AppendInt(b, int64(h), 10)
  384. b = append(b, lkt.timeSeparator...)
  385. if t.Minute() < 10 {
  386. b = append(b, '0')
  387. }
  388. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  389. b = append(b, lkt.timeSeparator...)
  390. if t.Second() < 10 {
  391. b = append(b, '0')
  392. }
  393. b = strconv.AppendInt(b, int64(t.Second()), 10)
  394. b = append(b, []byte{0x20}...)
  395. if t.Hour() < 12 {
  396. b = append(b, lkt.periodsAbbreviated[0]...)
  397. } else {
  398. b = append(b, lkt.periodsAbbreviated[1]...)
  399. }
  400. b = append(b, []byte{0x20}...)
  401. tz, _ := t.Zone()
  402. if btz, ok := lkt.timezones[tz]; ok {
  403. b = append(b, btz...)
  404. } else {
  405. b = append(b, tz...)
  406. }
  407. return string(b)
  408. }