ii_CN.go 18 KB

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