ln_CD.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. package ln_CD
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ln_CD 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 'ln_CD' locale
  41. func New() locales.Translator {
  42. return &ln_CD{
  43. locale: "ln_CD",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: ",",
  48. group: ".",
  49. minus: "-",
  50. percent: "%",
  51. perMille: "‰",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. 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"},
  55. currencyPositiveSuffix: " ",
  56. currencyNegativeSuffix: " ",
  57. monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"},
  58. monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"},
  59. monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"},
  60. daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"},
  61. daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"},
  62. daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"},
  63. periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"},
  64. periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"},
  65. erasAbbreviated: []string{"libóso ya", "nsima ya Y"},
  66. erasNarrow: []string{"", ""},
  67. erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"},
  68. timezones: map[string]string{"HNCU": "HNCU", "MDT": "MDT", "HNEG": "HNEG", "LHST": "LHST", "SRT": "SRT", "WIT": "WIT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "∅∅∅": "∅∅∅", "BOT": "BOT", "HEEG": "HEEG", "HNOG": "HNOG", "HEPM": "HEPM", "CST": "CST", "JST": "JST", "HEOG": "HEOG", "ACST": "ACST", "MEZ": "MEZ", "VET": "VET", "CLST": "CLST", "ART": "ART", "ARST": "ARST", "GYT": "GYT", "CHAST": "CHAST", "MST": "MST", "SAST": "Ntángo ya Afríka ya Sidi", "WAT": "WAT", "GFT": "GFT", "NZST": "NZST", "ECT": "ECT", "MESZ": "MESZ", "HKST": "HKST", "HECU": "HECU", "LHDT": "LHDT", "COST": "COST", "CDT": "CDT", "AWST": "AWST", "WEZ": "WEZ", "MYT": "MYT", "ACWST": "ACWST", "HNPM": "HNPM", "HEPMX": "HEPMX", "AKST": "AKST", "ACDT": "ACDT", "TMT": "TMT", "CLT": "CLT", "GMT": "Ntángo ya Londoni", "ADT": "ADT", "NZDT": "NZDT", "EDT": "EDT", "HNT": "HNT", "WARST": "WARST", "HAT": "HAT", "TMST": "TMST", "OESZ": "OESZ", "HADT": "HADT", "AEDT": "AEDT", "BT": "BT", "HKT": "HKT", "UYST": "UYST", "ChST": "ChST", "WAST": "WAST", "WESZ": "WESZ", "JDT": "JDT", "ACWDT": "ACWDT", "HAST": "HAST", "CHADT": "CHADT", "PDT": "PDT", "AWDT": "AWDT", "WART": "WART", "COT": "COT", "UYT": "UYT", "WIB": "WIB", "SGT": "SGT", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "PST": "PST", "AST": "AST", "HENOMX": "HENOMX", "AKDT": "AKDT", "IST": "IST", "OEZ": "OEZ", "AEST": "AEST", "EST": "EST", "WITA": "WITA", "CAT": "Ntángo ya Lubumbashi"},
  69. }
  70. }
  71. // Locale returns the current translators string locale
  72. func (ln *ln_CD) Locale() string {
  73. return ln.locale
  74. }
  75. // PluralsCardinal returns the list of cardinal plural rules associated with 'ln_CD'
  76. func (ln *ln_CD) PluralsCardinal() []locales.PluralRule {
  77. return ln.pluralsCardinal
  78. }
  79. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_CD'
  80. func (ln *ln_CD) PluralsOrdinal() []locales.PluralRule {
  81. return ln.pluralsOrdinal
  82. }
  83. // PluralsRange returns the list of range plural rules associated with 'ln_CD'
  84. func (ln *ln_CD) PluralsRange() []locales.PluralRule {
  85. return ln.pluralsRange
  86. }
  87. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD'
  88. func (ln *ln_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  89. n := math.Abs(num)
  90. if n >= 0 && n <= 1 {
  91. return locales.PluralRuleOne
  92. }
  93. return locales.PluralRuleOther
  94. }
  95. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD'
  96. func (ln *ln_CD) 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 'ln_CD'
  100. func (ln *ln_CD) 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 (ln *ln_CD) MonthAbbreviated(month time.Month) string {
  105. return ln.monthsAbbreviated[month]
  106. }
  107. // MonthsAbbreviated returns the locales abbreviated months
  108. func (ln *ln_CD) MonthsAbbreviated() []string {
  109. return ln.monthsAbbreviated[1:]
  110. }
  111. // MonthNarrow returns the locales narrow month given the 'month' provided
  112. func (ln *ln_CD) MonthNarrow(month time.Month) string {
  113. return ln.monthsNarrow[month]
  114. }
  115. // MonthsNarrow returns the locales narrow months
  116. func (ln *ln_CD) MonthsNarrow() []string {
  117. return ln.monthsNarrow[1:]
  118. }
  119. // MonthWide returns the locales wide month given the 'month' provided
  120. func (ln *ln_CD) MonthWide(month time.Month) string {
  121. return ln.monthsWide[month]
  122. }
  123. // MonthsWide returns the locales wide months
  124. func (ln *ln_CD) MonthsWide() []string {
  125. return ln.monthsWide[1:]
  126. }
  127. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  128. func (ln *ln_CD) WeekdayAbbreviated(weekday time.Weekday) string {
  129. return ln.daysAbbreviated[weekday]
  130. }
  131. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  132. func (ln *ln_CD) WeekdaysAbbreviated() []string {
  133. return ln.daysAbbreviated
  134. }
  135. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  136. func (ln *ln_CD) WeekdayNarrow(weekday time.Weekday) string {
  137. return ln.daysNarrow[weekday]
  138. }
  139. // WeekdaysNarrow returns the locales narrow weekdays
  140. func (ln *ln_CD) WeekdaysNarrow() []string {
  141. return ln.daysNarrow
  142. }
  143. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  144. func (ln *ln_CD) WeekdayShort(weekday time.Weekday) string {
  145. return ln.daysShort[weekday]
  146. }
  147. // WeekdaysShort returns the locales short weekdays
  148. func (ln *ln_CD) WeekdaysShort() []string {
  149. return ln.daysShort
  150. }
  151. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  152. func (ln *ln_CD) WeekdayWide(weekday time.Weekday) string {
  153. return ln.daysWide[weekday]
  154. }
  155. // WeekdaysWide returns the locales wide weekdays
  156. func (ln *ln_CD) WeekdaysWide() []string {
  157. return ln.daysWide
  158. }
  159. // Decimal returns the decimal point of number
  160. func (ln *ln_CD) Decimal() string {
  161. return ln.decimal
  162. }
  163. // Group returns the group of number
  164. func (ln *ln_CD) Group() string {
  165. return ln.group
  166. }
  167. // Group returns the minus sign of number
  168. func (ln *ln_CD) Minus() string {
  169. return ln.minus
  170. }
  171. // FmtNumber returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v'
  172. func (ln *ln_CD) FmtNumber(num float64, v uint64) string {
  173. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  174. l := len(s) + 2 + 1*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, ln.decimal[0])
  181. inWhole = true
  182. continue
  183. }
  184. if inWhole {
  185. if count == 3 {
  186. b = append(b, ln.group[0])
  187. count = 1
  188. } else {
  189. count++
  190. }
  191. }
  192. b = append(b, s[i])
  193. }
  194. if num < 0 {
  195. b = append(b, ln.minus[0])
  196. }
  197. // reverse
  198. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  199. b[i], b[j] = b[j], b[i]
  200. }
  201. return string(b)
  202. }
  203. // FmtPercent returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v'
  204. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  205. func (ln *ln_CD) FmtPercent(num float64, v uint64) string {
  206. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  207. }
  208. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD'
  209. func (ln *ln_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  210. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  211. symbol := ln.currencies[currency]
  212. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  213. count := 0
  214. inWhole := v == 0
  215. b := make([]byte, 0, l)
  216. for i := len(s) - 1; i >= 0; i-- {
  217. if s[i] == '.' {
  218. b = append(b, ln.decimal[0])
  219. inWhole = true
  220. continue
  221. }
  222. if inWhole {
  223. if count == 3 {
  224. b = append(b, ln.group[0])
  225. count = 1
  226. } else {
  227. count++
  228. }
  229. }
  230. b = append(b, s[i])
  231. }
  232. if num < 0 {
  233. b = append(b, ln.minus[0])
  234. }
  235. // reverse
  236. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  237. b[i], b[j] = b[j], b[i]
  238. }
  239. if int(v) < 2 {
  240. if v == 0 {
  241. b = append(b, ln.decimal...)
  242. }
  243. for i := 0; i < 2-int(v); i++ {
  244. b = append(b, '0')
  245. }
  246. }
  247. b = append(b, ln.currencyPositiveSuffix...)
  248. b = append(b, symbol...)
  249. return string(b)
  250. }
  251. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD'
  252. // in accounting notation.
  253. func (ln *ln_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  254. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  255. symbol := ln.currencies[currency]
  256. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  257. count := 0
  258. inWhole := v == 0
  259. b := make([]byte, 0, l)
  260. for i := len(s) - 1; i >= 0; i-- {
  261. if s[i] == '.' {
  262. b = append(b, ln.decimal[0])
  263. inWhole = true
  264. continue
  265. }
  266. if inWhole {
  267. if count == 3 {
  268. b = append(b, ln.group[0])
  269. count = 1
  270. } else {
  271. count++
  272. }
  273. }
  274. b = append(b, s[i])
  275. }
  276. if num < 0 {
  277. b = append(b, ln.minus[0])
  278. }
  279. // reverse
  280. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  281. b[i], b[j] = b[j], b[i]
  282. }
  283. if int(v) < 2 {
  284. if v == 0 {
  285. b = append(b, ln.decimal...)
  286. }
  287. for i := 0; i < 2-int(v); i++ {
  288. b = append(b, '0')
  289. }
  290. }
  291. if num < 0 {
  292. b = append(b, ln.currencyNegativeSuffix...)
  293. b = append(b, symbol...)
  294. } else {
  295. b = append(b, ln.currencyPositiveSuffix...)
  296. b = append(b, symbol...)
  297. }
  298. return string(b)
  299. }
  300. // FmtDateShort returns the short date representation of 't' for 'ln_CD'
  301. func (ln *ln_CD) FmtDateShort(t time.Time) string {
  302. b := make([]byte, 0, 32)
  303. b = strconv.AppendInt(b, int64(t.Day()), 10)
  304. b = append(b, []byte{0x2f}...)
  305. b = strconv.AppendInt(b, int64(t.Month()), 10)
  306. b = append(b, []byte{0x2f}...)
  307. if t.Year() > 0 {
  308. b = strconv.AppendInt(b, int64(t.Year()), 10)
  309. } else {
  310. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  311. }
  312. return string(b)
  313. }
  314. // FmtDateMedium returns the medium date representation of 't' for 'ln_CD'
  315. func (ln *ln_CD) FmtDateMedium(t time.Time) string {
  316. b := make([]byte, 0, 32)
  317. b = strconv.AppendInt(b, int64(t.Day()), 10)
  318. b = append(b, []byte{0x20}...)
  319. b = append(b, ln.monthsAbbreviated[t.Month()]...)
  320. b = append(b, []byte{0x20}...)
  321. if t.Year() > 0 {
  322. b = strconv.AppendInt(b, int64(t.Year()), 10)
  323. } else {
  324. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  325. }
  326. return string(b)
  327. }
  328. // FmtDateLong returns the long date representation of 't' for 'ln_CD'
  329. func (ln *ln_CD) FmtDateLong(t time.Time) string {
  330. b := make([]byte, 0, 32)
  331. b = strconv.AppendInt(b, int64(t.Day()), 10)
  332. b = append(b, []byte{0x20}...)
  333. b = append(b, ln.monthsWide[t.Month()]...)
  334. b = append(b, []byte{0x20}...)
  335. if t.Year() > 0 {
  336. b = strconv.AppendInt(b, int64(t.Year()), 10)
  337. } else {
  338. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  339. }
  340. return string(b)
  341. }
  342. // FmtDateFull returns the full date representation of 't' for 'ln_CD'
  343. func (ln *ln_CD) FmtDateFull(t time.Time) string {
  344. b := make([]byte, 0, 32)
  345. b = append(b, ln.daysWide[t.Weekday()]...)
  346. b = append(b, []byte{0x20}...)
  347. b = strconv.AppendInt(b, int64(t.Day()), 10)
  348. b = append(b, []byte{0x20}...)
  349. b = append(b, ln.monthsWide[t.Month()]...)
  350. b = append(b, []byte{0x20}...)
  351. if t.Year() > 0 {
  352. b = strconv.AppendInt(b, int64(t.Year()), 10)
  353. } else {
  354. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  355. }
  356. return string(b)
  357. }
  358. // FmtTimeShort returns the short time representation of 't' for 'ln_CD'
  359. func (ln *ln_CD) 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, ln.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 'ln_CD'
  373. func (ln *ln_CD) 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, ln.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, ln.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 'ln_CD'
  392. func (ln *ln_CD) 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, ln.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, ln.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 'ln_CD'
  414. func (ln *ln_CD) 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, ln.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, ln.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 := ln.timezones[tz]; ok {
  433. b = append(b, btz...)
  434. } else {
  435. b = append(b, tz...)
  436. }
  437. return string(b)
  438. }