kea_CV.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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", "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"},
  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{"CHAST": "CHAST", "AWDT": "Ora di Verãu di Australia Osidental", "AEST": "Ora Padrãu di Australia Oriental", "JST": "JST", "LHST": "LHST", "CDT": "Ora Sentral di Verãu", "AWST": "Ora Padrãu di Australia Osidental", "MST": "Ora di Montanha Padrãu", "MYT": "MYT", "HNEG": "HNEG", "IST": "IST", "ART": "ART", "ACWDT": "Ora di Verãu di Australia Sentru-Osidental", "HKST": "HKST", "WITA": "WITA", "GYT": "GYT", "HEPMX": "HEPMX", "AKST": "AKST", "EST": "Ora Oriental Padrãu", "ADT": "Ora di Verãu di Atlantiku", "HNPM": "HNPM", "CLT": "CLT", "NZST": "NZST", "BOT": "BOT", "SRT": "SRT", "UYST": "UYST", "HKT": "HKT", "WART": "WART", "HEPM": "HEPM", "OESZ": "Ora di Verãu di Europa Oriental", "ARST": "ARST", "HNPMX": "HNPMX", "WESZ": "Ora di Verãu di Europa Osidental", "ACWST": "Ora Padrãu di Australia Sentru-Osidental", "HNOG": "HNOG", "WARST": "WARST", "HNT": "HNT", "HAT": "HAT", "VET": "VET", "CLST": "CLST", "PST": "Ora di Pasifiku Padrãu", "AEDT": "Ora di Verãu di Australia Oriental", "WEZ": "Ora Padrãu di Europa Osidental", "AKDT": "AKDT", "HEEG": "HEEG", "MESZ": "Ora di Verãu di Europa Sentral", "TMT": "TMT", "WAT": "Ora Padrãu di Afrika Osidental", "JDT": "JDT", "NZDT": "NZDT", "EDT": "Ora Oriental di Verãu", "CAT": "Ora di Afrika Sentral", "GFT": "GFT", "SGT": "SGT", "ACST": "Ora Padrãu di Australia Sentral", "EAT": "Ora di Afrika Oriental", "WIT": "WIT", "MDT": "Ora di Verãu di Montanha", "TMST": "TMST", "HAST": "HAST", "HNCU": "HNCU", "HECU": "HECU", "AST": "Ora Padrãu di Atlantiku", "HEOG": "HEOG", "MEZ": "Ora Padrãu di Europa Sentral", "GMT": "GMT", "∅∅∅": "∅∅∅", "PDT": "Ora di Pasifiku di Verãu", "SAST": "Ora di Sul di Afrika", "ACDT": "Ora di Verãu di Australia Sentral", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "OEZ": "Ora Padrãu di Europa Oriental", "COST": "COST", "ChST": "ChST", "CST": "Ora Sentral Padrãu", "WIB": "WIB", "ECT": "ECT", "LHDT": "LHDT", "HADT": "HADT", "COT": "COT", "UYT": "UYT", "CHADT": "CHADT", "WAST": "Ora di Verão di Afrika Osidental", "BT": "BT"},
  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. // Decimal returns the decimal point of number
  160. func (kea *kea_CV) Decimal() string {
  161. return kea.decimal
  162. }
  163. // Group returns the group of number
  164. func (kea *kea_CV) Group() string {
  165. return kea.group
  166. }
  167. // Group returns the minus sign of number
  168. func (kea *kea_CV) Minus() string {
  169. return kea.minus
  170. }
  171. // FmtNumber returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v'
  172. func (kea *kea_CV) FmtNumber(num float64, v uint64) string {
  173. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  174. l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
  175. count := 0
  176. inWhole := v == 0
  177. b := make([]byte, 0, l)
  178. for i := len(s) - 1; i >= 0; i-- {
  179. if s[i] == '.' {
  180. b = append(b, kea.decimal[0])
  181. inWhole = true
  182. continue
  183. }
  184. if inWhole {
  185. if count == 3 {
  186. for j := len(kea.group) - 1; j >= 0; j-- {
  187. b = append(b, kea.group[j])
  188. }
  189. count = 1
  190. } else {
  191. count++
  192. }
  193. }
  194. b = append(b, s[i])
  195. }
  196. if num < 0 {
  197. b = append(b, kea.minus[0])
  198. }
  199. // reverse
  200. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  201. b[i], b[j] = b[j], b[i]
  202. }
  203. return string(b)
  204. }
  205. // FmtPercent returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v'
  206. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  207. func (kea *kea_CV) FmtPercent(num float64, v uint64) string {
  208. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  209. l := len(s) + 3
  210. b := make([]byte, 0, l)
  211. for i := len(s) - 1; i >= 0; i-- {
  212. if s[i] == '.' {
  213. b = append(b, kea.decimal[0])
  214. continue
  215. }
  216. b = append(b, s[i])
  217. }
  218. if num < 0 {
  219. b = append(b, kea.minus[0])
  220. }
  221. // reverse
  222. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  223. b[i], b[j] = b[j], b[i]
  224. }
  225. b = append(b, kea.percent...)
  226. return string(b)
  227. }
  228. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV'
  229. func (kea *kea_CV) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  230. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  231. symbol := kea.currencies[currency]
  232. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  233. count := 0
  234. inWhole := v == 0
  235. b := make([]byte, 0, l)
  236. for i := len(s) - 1; i >= 0; i-- {
  237. if s[i] == '.' {
  238. b = append(b, kea.decimal[0])
  239. inWhole = true
  240. continue
  241. }
  242. if inWhole {
  243. if count == 3 {
  244. for j := len(kea.group) - 1; j >= 0; j-- {
  245. b = append(b, kea.group[j])
  246. }
  247. count = 1
  248. } else {
  249. count++
  250. }
  251. }
  252. b = append(b, s[i])
  253. }
  254. if num < 0 {
  255. b = append(b, kea.minus[0])
  256. }
  257. // reverse
  258. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  259. b[i], b[j] = b[j], b[i]
  260. }
  261. if int(v) < 2 {
  262. if v == 0 {
  263. b = append(b, kea.decimal...)
  264. }
  265. for i := 0; i < 2-int(v); i++ {
  266. b = append(b, '0')
  267. }
  268. }
  269. b = append(b, kea.currencyPositiveSuffix...)
  270. b = append(b, symbol...)
  271. return string(b)
  272. }
  273. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV'
  274. // in accounting notation.
  275. func (kea *kea_CV) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  276. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  277. symbol := kea.currencies[currency]
  278. l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
  279. count := 0
  280. inWhole := v == 0
  281. b := make([]byte, 0, l)
  282. for i := len(s) - 1; i >= 0; i-- {
  283. if s[i] == '.' {
  284. b = append(b, kea.decimal[0])
  285. inWhole = true
  286. continue
  287. }
  288. if inWhole {
  289. if count == 3 {
  290. for j := len(kea.group) - 1; j >= 0; j-- {
  291. b = append(b, kea.group[j])
  292. }
  293. count = 1
  294. } else {
  295. count++
  296. }
  297. }
  298. b = append(b, s[i])
  299. }
  300. if num < 0 {
  301. b = append(b, kea.currencyNegativePrefix[0])
  302. }
  303. // reverse
  304. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  305. b[i], b[j] = b[j], b[i]
  306. }
  307. if int(v) < 2 {
  308. if v == 0 {
  309. b = append(b, kea.decimal...)
  310. }
  311. for i := 0; i < 2-int(v); i++ {
  312. b = append(b, '0')
  313. }
  314. }
  315. if num < 0 {
  316. b = append(b, kea.currencyNegativeSuffix...)
  317. b = append(b, symbol...)
  318. } else {
  319. b = append(b, kea.currencyPositiveSuffix...)
  320. b = append(b, symbol...)
  321. }
  322. return string(b)
  323. }
  324. // FmtDateShort returns the short date representation of 't' for 'kea_CV'
  325. func (kea *kea_CV) FmtDateShort(t time.Time) string {
  326. b := make([]byte, 0, 32)
  327. b = strconv.AppendInt(b, int64(t.Day()), 10)
  328. b = append(b, []byte{0x2f}...)
  329. b = strconv.AppendInt(b, int64(t.Month()), 10)
  330. b = append(b, []byte{0x2f}...)
  331. if t.Year() > 0 {
  332. b = strconv.AppendInt(b, int64(t.Year()), 10)
  333. } else {
  334. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  335. }
  336. return string(b)
  337. }
  338. // FmtDateMedium returns the medium date representation of 't' for 'kea_CV'
  339. func (kea *kea_CV) FmtDateMedium(t time.Time) string {
  340. b := make([]byte, 0, 32)
  341. b = strconv.AppendInt(b, int64(t.Day()), 10)
  342. b = append(b, []byte{0x20}...)
  343. b = append(b, kea.monthsAbbreviated[t.Month()]...)
  344. b = append(b, []byte{0x20}...)
  345. if t.Year() > 0 {
  346. b = strconv.AppendInt(b, int64(t.Year()), 10)
  347. } else {
  348. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  349. }
  350. return string(b)
  351. }
  352. // FmtDateLong returns the long date representation of 't' for 'kea_CV'
  353. func (kea *kea_CV) FmtDateLong(t time.Time) string {
  354. b := make([]byte, 0, 32)
  355. b = strconv.AppendInt(b, int64(t.Day()), 10)
  356. b = append(b, []byte{0x20, 0x64, 0x69}...)
  357. b = append(b, []byte{0x20}...)
  358. b = append(b, kea.monthsWide[t.Month()]...)
  359. b = append(b, []byte{0x20, 0x64, 0x69}...)
  360. b = append(b, []byte{0x20}...)
  361. if t.Year() > 0 {
  362. b = strconv.AppendInt(b, int64(t.Year()), 10)
  363. } else {
  364. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  365. }
  366. return string(b)
  367. }
  368. // FmtDateFull returns the full date representation of 't' for 'kea_CV'
  369. func (kea *kea_CV) FmtDateFull(t time.Time) string {
  370. b := make([]byte, 0, 32)
  371. b = append(b, kea.daysWide[t.Weekday()]...)
  372. b = append(b, []byte{0x2c, 0x20}...)
  373. b = strconv.AppendInt(b, int64(t.Day()), 10)
  374. b = append(b, []byte{0x20, 0x64, 0x69}...)
  375. b = append(b, []byte{0x20}...)
  376. b = append(b, kea.monthsWide[t.Month()]...)
  377. b = append(b, []byte{0x20, 0x64, 0x69}...)
  378. b = append(b, []byte{0x20}...)
  379. if t.Year() > 0 {
  380. b = strconv.AppendInt(b, int64(t.Year()), 10)
  381. } else {
  382. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  383. }
  384. return string(b)
  385. }
  386. // FmtTimeShort returns the short time representation of 't' for 'kea_CV'
  387. func (kea *kea_CV) FmtTimeShort(t time.Time) string {
  388. b := make([]byte, 0, 32)
  389. if t.Hour() < 10 {
  390. b = append(b, '0')
  391. }
  392. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  393. b = append(b, kea.timeSeparator...)
  394. if t.Minute() < 10 {
  395. b = append(b, '0')
  396. }
  397. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  398. return string(b)
  399. }
  400. // FmtTimeMedium returns the medium time representation of 't' for 'kea_CV'
  401. func (kea *kea_CV) FmtTimeMedium(t time.Time) string {
  402. b := make([]byte, 0, 32)
  403. if t.Hour() < 10 {
  404. b = append(b, '0')
  405. }
  406. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  407. b = append(b, kea.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, kea.timeSeparator...)
  413. if t.Second() < 10 {
  414. b = append(b, '0')
  415. }
  416. b = strconv.AppendInt(b, int64(t.Second()), 10)
  417. return string(b)
  418. }
  419. // FmtTimeLong returns the long time representation of 't' for 'kea_CV'
  420. func (kea *kea_CV) FmtTimeLong(t time.Time) string {
  421. b := make([]byte, 0, 32)
  422. if t.Hour() < 10 {
  423. b = append(b, '0')
  424. }
  425. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  426. b = append(b, kea.timeSeparator...)
  427. if t.Minute() < 10 {
  428. b = append(b, '0')
  429. }
  430. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  431. b = append(b, kea.timeSeparator...)
  432. if t.Second() < 10 {
  433. b = append(b, '0')
  434. }
  435. b = strconv.AppendInt(b, int64(t.Second()), 10)
  436. b = append(b, []byte{0x20}...)
  437. tz, _ := t.Zone()
  438. b = append(b, tz...)
  439. return string(b)
  440. }
  441. // FmtTimeFull returns the full time representation of 't' for 'kea_CV'
  442. func (kea *kea_CV) FmtTimeFull(t time.Time) string {
  443. b := make([]byte, 0, 32)
  444. if t.Hour() < 10 {
  445. b = append(b, '0')
  446. }
  447. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  448. b = append(b, kea.timeSeparator...)
  449. if t.Minute() < 10 {
  450. b = append(b, '0')
  451. }
  452. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  453. b = append(b, kea.timeSeparator...)
  454. if t.Second() < 10 {
  455. b = append(b, '0')
  456. }
  457. b = strconv.AppendInt(b, int64(t.Second()), 10)
  458. b = append(b, []byte{0x20}...)
  459. tz, _ := t.Zone()
  460. if btz, ok := kea.timezones[tz]; ok {
  461. b = append(b, btz...)
  462. } else {
  463. b = append(b, tz...)
  464. }
  465. return string(b)
  466. }