yav_CM.go 18 KB

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