kea_CV.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. package kea_CV
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type kea_CV 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. currencyNegativePrefix string
  24. currencyNegativeSuffix string
  25. monthsAbbreviated []string
  26. monthsNarrow []string
  27. monthsWide []string
  28. daysAbbreviated []string
  29. daysNarrow []string
  30. daysShort []string
  31. daysWide []string
  32. periodsAbbreviated []string
  33. periodsNarrow []string
  34. periodsShort []string
  35. periodsWide []string
  36. erasAbbreviated []string
  37. erasNarrow []string
  38. erasWide []string
  39. timezones map[string]string
  40. }
  41. // New returns a new instance of translator for the 'kea_CV' locale
  42. func New() locales.Translator {
  43. return &kea_CV{
  44. locale: "kea_CV",
  45. pluralsCardinal: []locales.PluralRule{6},
  46. pluralsOrdinal: nil,
  47. pluralsRange: nil,
  48. decimal: ",",
  49. group: " ",
  50. minus: "-",
  51. percent: "%",
  52. perMille: "‰",
  53. timeSeparator: ":",
  54. inifinity: "∞",
  55. 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 "},
  56. currencyPositiveSuffix: " ",
  57. currencyNegativePrefix: "(",
  58. currencyNegativeSuffix: " )",
  59. monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Otu", "Nuv", "Diz"},
  60. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  61. monthsWide: []string{"", "Janeru", "Febreru", "Marsu", "Abril", "Maiu", "Junhu", "Julhu", "Agostu", "Setenbru", "Otubru", "Nuvenbru", "Dizenbru"},
  62. daysAbbreviated: []string{"dum", "sig", "ter", "kua", "kin", "ses", "sab"},
  63. daysNarrow: []string{"D", "S", "T", "K", "K", "S", "S"},
  64. daysShort: []string{"du", "si", "te", "ku", "ki", "se", "sa"},
  65. daysWide: []string{"dumingu", "sigunda-fera", "tersa-fera", "kuarta-fera", "kinta-fera", "sesta-fera", "sabadu"},
  66. periodsAbbreviated: []string{"am", "pm"},
  67. periodsNarrow: []string{"a", "p"},
  68. periodsWide: []string{"am", "pm"},
  69. erasAbbreviated: []string{"AK", "DK"},
  70. erasNarrow: []string{"", ""},
  71. erasWide: []string{"Antis di Kristu", "Dispos di Kristu"},
  72. timezones: map[string]string{"AEDT": "Ora di Verãu di Australia Oriental", "HKST": "HKST", "∅∅∅": "∅∅∅", "AWDT": "Ora di Verãu di Australia Osidental", "GYT": "GYT", "MYT": "MYT", "MEZ": "Ora Padrãu di Europa Sentral", "AEST": "Ora Padrãu di Australia Oriental", "WART": "WART", "ARST": "ARST", "HAST": "HAST", "WIT": "WIT", "NZST": "NZST", "BOT": "BOT", "UYT": "UYT", "ChST": "ChST", "EDT": "Ora Oriental di Verãu", "AKST": "AKST", "LHDT": "LHDT", "VET": "VET", "WESZ": "Ora di Verãu di Europa Osidental", "EAT": "Ora di Afrika Oriental", "ACST": "Ora Padrãu di Australia Sentral", "SRT": "SRT", "PST": "Ora di Pasifiku Padrãu", "NZDT": "NZDT", "UYST": "UYST", "WIB": "WIB", "IST": "IST", "GMT": "GMT", "MST": "MST", "TMT": "TMT", "WAST": "Ora di Verão di Afrika Osidental", "HNT": "HNT", "ART": "ART", "CLT": "CLT", "COT": "COT", "COST": "COST", "WAT": "Ora Padrãu di Afrika Osidental", "AKDT": "AKDT", "WEZ": "Ora Padrãu di Europa Osidental", "ECT": "ECT", "ADT": "Ora di Verãu di Atlantiku", "SGT": "SGT", "SAST": "Ora di Sul di Afrika", "WITA": "WITA", "JST": "JST", "JDT": "JDT", "CHAST": "CHAST", "HKT": "HKT", "OEZ": "Ora Padrãu di Europa Oriental", "PDT": "Ora di Pasifiku di Verãu", "CLST": "CLST", "WARST": "WARST", "OESZ": "Ora di Verãu di Europa Oriental", "GFT": "GFT", "LHST": "LHST", "CST": "Ora Sentral Padrãu", "ACWDT": "Ora di Verãu di Australia Sentru-Osidental", "CAT": "Ora di Afrika Sentral", "MDT": "MDT", "AWST": "Ora Padrãu di Australia Osidental", "TMST": "TMST", "CDT": "Ora Sentral di Verãu", "EST": "Ora Oriental Padrãu", "AST": "Ora Padrãu di Atlantiku", "HAT": "HAT", "ACDT": "Ora di Verãu di Australia Sentral", "MESZ": "Ora di Verãu di Europa Sentral", "HADT": "HADT", "BT": "BT", "ACWST": "Ora Padrãu di Australia Sentru-Osidental", "CHADT": "CHADT"},
  73. }
  74. }
  75. // Locale returns the current translators string locale
  76. func (kea *kea_CV) Locale() string {
  77. return kea.locale
  78. }
  79. // PluralsCardinal returns the list of cardinal plural rules associated with 'kea_CV'
  80. func (kea *kea_CV) PluralsCardinal() []locales.PluralRule {
  81. return kea.pluralsCardinal
  82. }
  83. // PluralsOrdinal returns the list of ordinal plural rules associated with 'kea_CV'
  84. func (kea *kea_CV) PluralsOrdinal() []locales.PluralRule {
  85. return kea.pluralsOrdinal
  86. }
  87. // PluralsRange returns the list of range plural rules associated with 'kea_CV'
  88. func (kea *kea_CV) PluralsRange() []locales.PluralRule {
  89. return kea.pluralsRange
  90. }
  91. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kea_CV'
  92. func (kea *kea_CV) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  93. return locales.PluralRuleOther
  94. }
  95. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kea_CV'
  96. func (kea *kea_CV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  97. return locales.PluralRuleUnknown
  98. }
  99. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kea_CV'
  100. func (kea *kea_CV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  101. return locales.PluralRuleUnknown
  102. }
  103. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  104. func (kea *kea_CV) MonthAbbreviated(month time.Month) string {
  105. return kea.monthsAbbreviated[month]
  106. }
  107. // MonthsAbbreviated returns the locales abbreviated months
  108. func (kea *kea_CV) MonthsAbbreviated() []string {
  109. return kea.monthsAbbreviated[1:]
  110. }
  111. // MonthNarrow returns the locales narrow month given the 'month' provided
  112. func (kea *kea_CV) MonthNarrow(month time.Month) string {
  113. return kea.monthsNarrow[month]
  114. }
  115. // MonthsNarrow returns the locales narrow months
  116. func (kea *kea_CV) MonthsNarrow() []string {
  117. return kea.monthsNarrow[1:]
  118. }
  119. // MonthWide returns the locales wide month given the 'month' provided
  120. func (kea *kea_CV) MonthWide(month time.Month) string {
  121. return kea.monthsWide[month]
  122. }
  123. // MonthsWide returns the locales wide months
  124. func (kea *kea_CV) MonthsWide() []string {
  125. return kea.monthsWide[1:]
  126. }
  127. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  128. func (kea *kea_CV) WeekdayAbbreviated(weekday time.Weekday) string {
  129. return kea.daysAbbreviated[weekday]
  130. }
  131. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  132. func (kea *kea_CV) WeekdaysAbbreviated() []string {
  133. return kea.daysAbbreviated
  134. }
  135. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  136. func (kea *kea_CV) WeekdayNarrow(weekday time.Weekday) string {
  137. return kea.daysNarrow[weekday]
  138. }
  139. // WeekdaysNarrow returns the locales narrow weekdays
  140. func (kea *kea_CV) WeekdaysNarrow() []string {
  141. return kea.daysNarrow
  142. }
  143. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  144. func (kea *kea_CV) WeekdayShort(weekday time.Weekday) string {
  145. return kea.daysShort[weekday]
  146. }
  147. // WeekdaysShort returns the locales short weekdays
  148. func (kea *kea_CV) WeekdaysShort() []string {
  149. return kea.daysShort
  150. }
  151. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  152. func (kea *kea_CV) WeekdayWide(weekday time.Weekday) string {
  153. return kea.daysWide[weekday]
  154. }
  155. // WeekdaysWide returns the locales wide weekdays
  156. func (kea *kea_CV) WeekdaysWide() []string {
  157. return kea.daysWide
  158. }
  159. // FmtNumber returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v'
  160. func (kea *kea_CV) FmtNumber(num float64, v uint64) string {
  161. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  162. l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
  163. count := 0
  164. inWhole := v == 0
  165. b := make([]byte, 0, l)
  166. for i := len(s) - 1; i >= 0; i-- {
  167. if s[i] == '.' {
  168. b = append(b, kea.decimal[0])
  169. inWhole = true
  170. continue
  171. }
  172. if inWhole {
  173. if count == 3 {
  174. for j := len(kea.group) - 1; j >= 0; j-- {
  175. b = append(b, kea.group[j])
  176. }
  177. count = 1
  178. } else {
  179. count++
  180. }
  181. }
  182. b = append(b, s[i])
  183. }
  184. if num < 0 {
  185. b = append(b, kea.minus[0])
  186. }
  187. // reverse
  188. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  189. b[i], b[j] = b[j], b[i]
  190. }
  191. return string(b)
  192. }
  193. // FmtPercent returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v'
  194. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  195. func (kea *kea_CV) FmtPercent(num float64, v uint64) string {
  196. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  197. l := len(s) + 3
  198. b := make([]byte, 0, l)
  199. for i := len(s) - 1; i >= 0; i-- {
  200. if s[i] == '.' {
  201. b = append(b, kea.decimal[0])
  202. continue
  203. }
  204. b = append(b, s[i])
  205. }
  206. if num < 0 {
  207. b = append(b, kea.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. b = append(b, kea.percent...)
  214. return string(b)
  215. }
  216. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV'
  217. func (kea *kea_CV) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  218. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  219. symbol := kea.currencies[currency]
  220. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  221. count := 0
  222. inWhole := v == 0
  223. b := make([]byte, 0, l)
  224. for i := len(s) - 1; i >= 0; i-- {
  225. if s[i] == '.' {
  226. b = append(b, kea.decimal[0])
  227. inWhole = true
  228. continue
  229. }
  230. if inWhole {
  231. if count == 3 {
  232. for j := len(kea.group) - 1; j >= 0; j-- {
  233. b = append(b, kea.group[j])
  234. }
  235. count = 1
  236. } else {
  237. count++
  238. }
  239. }
  240. b = append(b, s[i])
  241. }
  242. if num < 0 {
  243. b = append(b, kea.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, kea.decimal...)
  252. }
  253. for i := 0; i < 2-int(v); i++ {
  254. b = append(b, '0')
  255. }
  256. }
  257. b = append(b, kea.currencyPositiveSuffix...)
  258. b = append(b, symbol...)
  259. return string(b)
  260. }
  261. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV'
  262. // in accounting notation.
  263. func (kea *kea_CV) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  264. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  265. symbol := kea.currencies[currency]
  266. l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
  267. count := 0
  268. inWhole := v == 0
  269. b := make([]byte, 0, l)
  270. for i := len(s) - 1; i >= 0; i-- {
  271. if s[i] == '.' {
  272. b = append(b, kea.decimal[0])
  273. inWhole = true
  274. continue
  275. }
  276. if inWhole {
  277. if count == 3 {
  278. for j := len(kea.group) - 1; j >= 0; j-- {
  279. b = append(b, kea.group[j])
  280. }
  281. count = 1
  282. } else {
  283. count++
  284. }
  285. }
  286. b = append(b, s[i])
  287. }
  288. if num < 0 {
  289. b = append(b, kea.currencyNegativePrefix[0])
  290. }
  291. // reverse
  292. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  293. b[i], b[j] = b[j], b[i]
  294. }
  295. if int(v) < 2 {
  296. if v == 0 {
  297. b = append(b, kea.decimal...)
  298. }
  299. for i := 0; i < 2-int(v); i++ {
  300. b = append(b, '0')
  301. }
  302. }
  303. if num < 0 {
  304. b = append(b, kea.currencyNegativeSuffix...)
  305. b = append(b, symbol...)
  306. } else {
  307. b = append(b, kea.currencyPositiveSuffix...)
  308. b = append(b, symbol...)
  309. }
  310. return string(b)
  311. }
  312. // FmtDateShort returns the short date representation of 't' for 'kea_CV'
  313. func (kea *kea_CV) FmtDateShort(t time.Time) string {
  314. b := make([]byte, 0, 32)
  315. b = strconv.AppendInt(b, int64(t.Day()), 10)
  316. b = append(b, []byte{0x2f}...)
  317. b = strconv.AppendInt(b, int64(t.Month()), 10)
  318. b = append(b, []byte{0x2f}...)
  319. b = strconv.AppendInt(b, int64(t.Year()), 10)
  320. return string(b)
  321. }
  322. // FmtDateMedium returns the medium date representation of 't' for 'kea_CV'
  323. func (kea *kea_CV) FmtDateMedium(t time.Time) string {
  324. b := make([]byte, 0, 32)
  325. b = strconv.AppendInt(b, int64(t.Day()), 10)
  326. b = append(b, []byte{0x20}...)
  327. b = append(b, kea.monthsAbbreviated[t.Month()]...)
  328. b = append(b, []byte{0x20}...)
  329. b = strconv.AppendInt(b, int64(t.Year()), 10)
  330. return string(b)
  331. }
  332. // FmtDateLong returns the long date representation of 't' for 'kea_CV'
  333. func (kea *kea_CV) FmtDateLong(t time.Time) string {
  334. b := make([]byte, 0, 32)
  335. b = strconv.AppendInt(b, int64(t.Day()), 10)
  336. b = append(b, []byte{}...)
  337. b = append(b, []byte{0x27, 0x64, 0x69, 0x27, 0x20}...)
  338. b = append(b, kea.monthsWide[t.Month()]...)
  339. b = append(b, []byte{}...)
  340. b = append(b, []byte{0x27, 0x64, 0x69, 0x27, 0x20}...)
  341. b = strconv.AppendInt(b, int64(t.Year()), 10)
  342. return string(b)
  343. }
  344. // FmtDateFull returns the full date representation of 't' for 'kea_CV'
  345. func (kea *kea_CV) FmtDateFull(t time.Time) string {
  346. b := make([]byte, 0, 32)
  347. b = append(b, kea.daysWide[t.Weekday()]...)
  348. b = append(b, []byte{0x2c, 0x20}...)
  349. b = strconv.AppendInt(b, int64(t.Day()), 10)
  350. b = append(b, []byte{}...)
  351. b = append(b, []byte{0x27, 0x64, 0x69, 0x27, 0x20}...)
  352. b = append(b, kea.monthsWide[t.Month()]...)
  353. b = append(b, []byte{}...)
  354. b = append(b, []byte{0x27, 0x64, 0x69, 0x27, 0x20}...)
  355. b = strconv.AppendInt(b, int64(t.Year()), 10)
  356. return string(b)
  357. }
  358. // FmtTimeShort returns the short time representation of 't' for 'kea_CV'
  359. func (kea *kea_CV) FmtTimeShort(t time.Time) string {
  360. b := make([]byte, 0, 32)
  361. if t.Hour() < 10 {
  362. b = append(b, '0')
  363. }
  364. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  365. b = append(b, kea.timeSeparator...)
  366. if t.Minute() < 10 {
  367. b = append(b, '0')
  368. }
  369. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  370. return string(b)
  371. }
  372. // FmtTimeMedium returns the medium time representation of 't' for 'kea_CV'
  373. func (kea *kea_CV) FmtTimeMedium(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, kea.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, kea.timeSeparator...)
  385. if t.Second() < 10 {
  386. b = append(b, '0')
  387. }
  388. b = strconv.AppendInt(b, int64(t.Second()), 10)
  389. return string(b)
  390. }
  391. // FmtTimeLong returns the long time representation of 't' for 'kea_CV'
  392. func (kea *kea_CV) FmtTimeLong(t time.Time) string {
  393. b := make([]byte, 0, 32)
  394. if t.Hour() < 10 {
  395. b = append(b, '0')
  396. }
  397. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  398. b = append(b, kea.timeSeparator...)
  399. if t.Minute() < 10 {
  400. b = append(b, '0')
  401. }
  402. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  403. b = append(b, kea.timeSeparator...)
  404. if t.Second() < 10 {
  405. b = append(b, '0')
  406. }
  407. b = strconv.AppendInt(b, int64(t.Second()), 10)
  408. b = append(b, []byte{0x20}...)
  409. tz, _ := t.Zone()
  410. b = append(b, tz...)
  411. return string(b)
  412. }
  413. // FmtTimeFull returns the full time representation of 't' for 'kea_CV'
  414. func (kea *kea_CV) FmtTimeFull(t time.Time) string {
  415. b := make([]byte, 0, 32)
  416. if t.Hour() < 10 {
  417. b = append(b, '0')
  418. }
  419. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  420. b = append(b, kea.timeSeparator...)
  421. if t.Minute() < 10 {
  422. b = append(b, '0')
  423. }
  424. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  425. b = append(b, kea.timeSeparator...)
  426. if t.Second() < 10 {
  427. b = append(b, '0')
  428. }
  429. b = strconv.AppendInt(b, int64(t.Second()), 10)
  430. b = append(b, []byte{0x20}...)
  431. tz, _ := t.Zone()
  432. if btz, ok := kea.timezones[tz]; ok {
  433. b = append(b, btz...)
  434. } else {
  435. b = append(b, tz...)
  436. }
  437. return string(b)
  438. }