ksf.go 17 KB

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