it_CH.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. package it_CH
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type it_CH 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 'it_CH' locale
  41. func New() locales.Translator {
  42. return &it_CH{
  43. locale: "it_CH",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{5, 6},
  46. pluralsRange: []locales.PluralRule{2, 6},
  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. currencyPositivePrefix: " ",
  56. currencyNegativePrefix: " ",
  57. monthsAbbreviated: []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"},
  58. monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"},
  59. monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"},
  60. daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
  61. daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"},
  62. daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
  63. daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"m.", "p."},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"a.C.", "d.C."},
  68. erasNarrow: []string{"aC", "dC"},
  69. erasWide: []string{"avanti Cristo", "dopo Cristo"},
  70. timezones: map[string]string{"HEPM": "Ora legale di Saint-Pierre e Miquelon", "TMT": "Ora standard del Turkmenistan", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "CHADT": "Ora legale delle Chatham", "HECU": "Ora legale di Cuba", "WIB": "Ora dell’Indonesia occidentale", "HNT": "Ora standard di Terranova", "WARST": "Ora legale dell’Argentina occidentale", "AWST": "Ora standard dell’Australia occidentale", "WAST": "Ora legale dell’Africa occidentale", "HNEG": "Ora standard della Groenlandia orientale", "MESZ": "Ora legale dell’Europa centrale", "COST": "Ora legale della Colombia", "AEDT": "Ora legale dell’Australia orientale", "NZDT": "Ora legale della Nuova Zelanda", "AKST": "Ora standard dell’Alaska", "ACWDT": "Ora legale dell’Australia centroccidentale", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "ARST": "Ora legale dell’Argentina", "GYT": "Ora della Guyana", "SGT": "Ora di Singapore", "VET": "Ora del Venezuela", "CLST": "Ora legale del Cile", "NZST": "Ora standard della Nuova Zelanda", "AKDT": "Ora legale dell’Alaska", "HKT": "Ora standard di Hong Kong", "WIT": "Ora dell’Indonesia orientale", "PST": "Ora standard del Pacifico USA", "MDT": "Ora legale Montagne Rocciose USA", "SAST": "Ora dell’Africa meridionale", "BT": "Ora del Bhutan", "HAT": "Ora legale di Terranova", "GMT": "Ora del meridiano di Greenwich", "HNOG": "Ora standard della Groenlandia occidentale", "IST": "Ora standard dell’India", "LHDT": "Ora legale di Lord Howe", "WART": "Ora standard dell’Argentina occidentale", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "WEZ": "Ora standard dell’Europa occidentale", "BOT": "Ora della Bolivia", "HENOMX": "Ora legale del Messico nord-occidentale", "CAT": "Ora dell’Africa centrale", "CST": "Ora standard centrale USA", "MYT": "Ora della Malesia", "ART": "Ora standard dell’Argentina", "GFT": "Ora della Guiana francese", "HKST": "Ora legale di Hong Kong", "SRT": "Ora del Suriname", "UYST": "Ora legale dell’Uruguay", "CDT": "Ora legale centrale USA", "HEPMX": "Ora legale del Pacifico (Messico)", "ADT": "Ora legale dell’Atlantico", "OESZ": "Ora legale dell’Europa orientale", "COT": "Ora standard della Colombia", "CHAST": "Ora standard delle Chatham", "HNCU": "Ora standard di Cuba", "AEST": "Ora standard dell’Australia orientale", "WITA": "Ora dell’Indonesia centrale", "CLT": "Ora standard del Cile", "WAT": "Ora standard dell’Africa occidentale", "JST": "Ora standard del Giappone", "ACST": "Ora standard dell’Australia centrale", "ACDT": "Ora legale dell’Australia centrale", "ChST": "Ora di Chamorro", "WESZ": "Ora legale dell’Europa occidentale", "ECT": "Ora dell’Ecuador", "LHST": "Ora standard di Lord Howe", "EAT": "Ora dell’Africa orientale", "UYT": "Ora standard dell’Uruguay", "HNPMX": "Ora standard del Pacifico (Messico)", "EST": "Ora standard orientale USA", "HEEG": "Ora legale della Groenlandia orientale", "EDT": "Ora legale orientale USA", "MEZ": "Ora standard dell’Europa centrale", "OEZ": "Ora standard dell’Europa orientale", "∅∅∅": "Ora legale di Brasilia", "PDT": "Ora legale del Pacifico USA", "MST": "Ora standard Montagne Rocciose USA", "JDT": "Ora legale del Giappone", "HNNOMX": "Ora standard del Messico nord-occidentale", "TMST": "Ora legale del Turkmenistan", "AWDT": "Ora legale dell’Australia occidentale", "AST": "Ora standard dell’Atlantico", "ACWST": "Ora standard dell’Australia centroccidentale", "HEOG": "Ora legale della Groenlandia occidentale"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (it *it_CH) Locale() string {
  75. return it.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'it_CH'
  78. func (it *it_CH) PluralsCardinal() []locales.PluralRule {
  79. return it.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'it_CH'
  82. func (it *it_CH) PluralsOrdinal() []locales.PluralRule {
  83. return it.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'it_CH'
  86. func (it *it_CH) PluralsRange() []locales.PluralRule {
  87. return it.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH'
  90. func (it *it_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. if i == 1 && v == 0 {
  94. return locales.PluralRuleOne
  95. }
  96. return locales.PluralRuleOther
  97. }
  98. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH'
  99. func (it *it_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  100. n := math.Abs(num)
  101. if n == 11 || n == 8 || n == 80 || n == 800 {
  102. return locales.PluralRuleMany
  103. }
  104. return locales.PluralRuleOther
  105. }
  106. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_CH'
  107. func (it *it_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  108. start := it.CardinalPluralRule(num1, v1)
  109. end := it.CardinalPluralRule(num2, v2)
  110. if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  111. return locales.PluralRuleOther
  112. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  113. return locales.PluralRuleOne
  114. }
  115. return locales.PluralRuleOther
  116. }
  117. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  118. func (it *it_CH) MonthAbbreviated(month time.Month) string {
  119. return it.monthsAbbreviated[month]
  120. }
  121. // MonthsAbbreviated returns the locales abbreviated months
  122. func (it *it_CH) MonthsAbbreviated() []string {
  123. return it.monthsAbbreviated[1:]
  124. }
  125. // MonthNarrow returns the locales narrow month given the 'month' provided
  126. func (it *it_CH) MonthNarrow(month time.Month) string {
  127. return it.monthsNarrow[month]
  128. }
  129. // MonthsNarrow returns the locales narrow months
  130. func (it *it_CH) MonthsNarrow() []string {
  131. return it.monthsNarrow[1:]
  132. }
  133. // MonthWide returns the locales wide month given the 'month' provided
  134. func (it *it_CH) MonthWide(month time.Month) string {
  135. return it.monthsWide[month]
  136. }
  137. // MonthsWide returns the locales wide months
  138. func (it *it_CH) MonthsWide() []string {
  139. return it.monthsWide[1:]
  140. }
  141. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  142. func (it *it_CH) WeekdayAbbreviated(weekday time.Weekday) string {
  143. return it.daysAbbreviated[weekday]
  144. }
  145. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  146. func (it *it_CH) WeekdaysAbbreviated() []string {
  147. return it.daysAbbreviated
  148. }
  149. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  150. func (it *it_CH) WeekdayNarrow(weekday time.Weekday) string {
  151. return it.daysNarrow[weekday]
  152. }
  153. // WeekdaysNarrow returns the locales narrow weekdays
  154. func (it *it_CH) WeekdaysNarrow() []string {
  155. return it.daysNarrow
  156. }
  157. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  158. func (it *it_CH) WeekdayShort(weekday time.Weekday) string {
  159. return it.daysShort[weekday]
  160. }
  161. // WeekdaysShort returns the locales short weekdays
  162. func (it *it_CH) WeekdaysShort() []string {
  163. return it.daysShort
  164. }
  165. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  166. func (it *it_CH) WeekdayWide(weekday time.Weekday) string {
  167. return it.daysWide[weekday]
  168. }
  169. // WeekdaysWide returns the locales wide weekdays
  170. func (it *it_CH) WeekdaysWide() []string {
  171. return it.daysWide
  172. }
  173. // Decimal returns the decimal point of number
  174. func (it *it_CH) Decimal() string {
  175. return it.decimal
  176. }
  177. // Group returns the group of number
  178. func (it *it_CH) Group() string {
  179. return it.group
  180. }
  181. // Group returns the minus sign of number
  182. func (it *it_CH) Minus() string {
  183. return it.minus
  184. }
  185. // FmtNumber returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
  186. func (it *it_CH) FmtNumber(num float64, v uint64) string {
  187. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  188. l := len(s) + 2 + 3*len(s[:len(s)-int(v)-1])/3
  189. count := 0
  190. inWhole := v == 0
  191. b := make([]byte, 0, l)
  192. for i := len(s) - 1; i >= 0; i-- {
  193. if s[i] == '.' {
  194. b = append(b, it.decimal[0])
  195. inWhole = true
  196. continue
  197. }
  198. if inWhole {
  199. if count == 3 {
  200. for j := len(it.group) - 1; j >= 0; j-- {
  201. b = append(b, it.group[j])
  202. }
  203. count = 1
  204. } else {
  205. count++
  206. }
  207. }
  208. b = append(b, s[i])
  209. }
  210. if num < 0 {
  211. b = append(b, it.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. return string(b)
  218. }
  219. // FmtPercent returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
  220. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  221. func (it *it_CH) FmtPercent(num float64, v uint64) string {
  222. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  223. l := len(s) + 3
  224. b := make([]byte, 0, l)
  225. for i := len(s) - 1; i >= 0; i-- {
  226. if s[i] == '.' {
  227. b = append(b, it.decimal[0])
  228. continue
  229. }
  230. b = append(b, s[i])
  231. }
  232. if num < 0 {
  233. b = append(b, it.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. b = append(b, it.percent...)
  240. return string(b)
  241. }
  242. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
  243. func (it *it_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  244. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  245. symbol := it.currencies[currency]
  246. l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
  247. count := 0
  248. inWhole := v == 0
  249. b := make([]byte, 0, l)
  250. for i := len(s) - 1; i >= 0; i-- {
  251. if s[i] == '.' {
  252. b = append(b, it.decimal[0])
  253. inWhole = true
  254. continue
  255. }
  256. if inWhole {
  257. if count == 3 {
  258. for j := len(it.group) - 1; j >= 0; j-- {
  259. b = append(b, it.group[j])
  260. }
  261. count = 1
  262. } else {
  263. count++
  264. }
  265. }
  266. b = append(b, s[i])
  267. }
  268. for j := len(symbol) - 1; j >= 0; j-- {
  269. b = append(b, symbol[j])
  270. }
  271. for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
  272. b = append(b, it.currencyPositivePrefix[j])
  273. }
  274. if num < 0 {
  275. b = append(b, it.minus[0])
  276. }
  277. // reverse
  278. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  279. b[i], b[j] = b[j], b[i]
  280. }
  281. if int(v) < 2 {
  282. if v == 0 {
  283. b = append(b, it.decimal...)
  284. }
  285. for i := 0; i < 2-int(v); i++ {
  286. b = append(b, '0')
  287. }
  288. }
  289. return string(b)
  290. }
  291. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
  292. // in accounting notation.
  293. func (it *it_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  294. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  295. symbol := it.currencies[currency]
  296. l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
  297. count := 0
  298. inWhole := v == 0
  299. b := make([]byte, 0, l)
  300. for i := len(s) - 1; i >= 0; i-- {
  301. if s[i] == '.' {
  302. b = append(b, it.decimal[0])
  303. inWhole = true
  304. continue
  305. }
  306. if inWhole {
  307. if count == 3 {
  308. for j := len(it.group) - 1; j >= 0; j-- {
  309. b = append(b, it.group[j])
  310. }
  311. count = 1
  312. } else {
  313. count++
  314. }
  315. }
  316. b = append(b, s[i])
  317. }
  318. if num < 0 {
  319. for j := len(symbol) - 1; j >= 0; j-- {
  320. b = append(b, symbol[j])
  321. }
  322. for j := len(it.currencyNegativePrefix) - 1; j >= 0; j-- {
  323. b = append(b, it.currencyNegativePrefix[j])
  324. }
  325. b = append(b, it.minus[0])
  326. } else {
  327. for j := len(symbol) - 1; j >= 0; j-- {
  328. b = append(b, symbol[j])
  329. }
  330. for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
  331. b = append(b, it.currencyPositivePrefix[j])
  332. }
  333. }
  334. // reverse
  335. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  336. b[i], b[j] = b[j], b[i]
  337. }
  338. if int(v) < 2 {
  339. if v == 0 {
  340. b = append(b, it.decimal...)
  341. }
  342. for i := 0; i < 2-int(v); i++ {
  343. b = append(b, '0')
  344. }
  345. }
  346. return string(b)
  347. }
  348. // FmtDateShort returns the short date representation of 't' for 'it_CH'
  349. func (it *it_CH) FmtDateShort(t time.Time) string {
  350. b := make([]byte, 0, 32)
  351. if t.Day() < 10 {
  352. b = append(b, '0')
  353. }
  354. b = strconv.AppendInt(b, int64(t.Day()), 10)
  355. b = append(b, []byte{0x2e}...)
  356. if t.Month() < 10 {
  357. b = append(b, '0')
  358. }
  359. b = strconv.AppendInt(b, int64(t.Month()), 10)
  360. b = append(b, []byte{0x2e}...)
  361. if t.Year() > 9 {
  362. b = append(b, strconv.Itoa(t.Year())[2:]...)
  363. } else {
  364. b = append(b, strconv.Itoa(t.Year())[1:]...)
  365. }
  366. return string(b)
  367. }
  368. // FmtDateMedium returns the medium date representation of 't' for 'it_CH'
  369. func (it *it_CH) FmtDateMedium(t time.Time) string {
  370. b := make([]byte, 0, 32)
  371. b = strconv.AppendInt(b, int64(t.Day()), 10)
  372. b = append(b, []byte{0x20}...)
  373. b = append(b, it.monthsAbbreviated[t.Month()]...)
  374. b = append(b, []byte{0x20}...)
  375. if t.Year() > 0 {
  376. b = strconv.AppendInt(b, int64(t.Year()), 10)
  377. } else {
  378. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  379. }
  380. return string(b)
  381. }
  382. // FmtDateLong returns the long date representation of 't' for 'it_CH'
  383. func (it *it_CH) FmtDateLong(t time.Time) string {
  384. b := make([]byte, 0, 32)
  385. b = strconv.AppendInt(b, int64(t.Day()), 10)
  386. b = append(b, []byte{0x20}...)
  387. b = append(b, it.monthsWide[t.Month()]...)
  388. b = append(b, []byte{0x20}...)
  389. if t.Year() > 0 {
  390. b = strconv.AppendInt(b, int64(t.Year()), 10)
  391. } else {
  392. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  393. }
  394. return string(b)
  395. }
  396. // FmtDateFull returns the full date representation of 't' for 'it_CH'
  397. func (it *it_CH) FmtDateFull(t time.Time) string {
  398. b := make([]byte, 0, 32)
  399. b = append(b, it.daysWide[t.Weekday()]...)
  400. b = append(b, []byte{0x2c, 0x20}...)
  401. b = strconv.AppendInt(b, int64(t.Day()), 10)
  402. b = append(b, []byte{0x20}...)
  403. b = append(b, it.monthsWide[t.Month()]...)
  404. b = append(b, []byte{0x20}...)
  405. if t.Year() > 0 {
  406. b = strconv.AppendInt(b, int64(t.Year()), 10)
  407. } else {
  408. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  409. }
  410. return string(b)
  411. }
  412. // FmtTimeShort returns the short time representation of 't' for 'it_CH'
  413. func (it *it_CH) FmtTimeShort(t time.Time) string {
  414. b := make([]byte, 0, 32)
  415. if t.Hour() < 10 {
  416. b = append(b, '0')
  417. }
  418. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  419. b = append(b, it.timeSeparator...)
  420. if t.Minute() < 10 {
  421. b = append(b, '0')
  422. }
  423. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  424. return string(b)
  425. }
  426. // FmtTimeMedium returns the medium time representation of 't' for 'it_CH'
  427. func (it *it_CH) FmtTimeMedium(t time.Time) string {
  428. b := make([]byte, 0, 32)
  429. if t.Hour() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  433. b = append(b, it.timeSeparator...)
  434. if t.Minute() < 10 {
  435. b = append(b, '0')
  436. }
  437. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  438. b = append(b, it.timeSeparator...)
  439. if t.Second() < 10 {
  440. b = append(b, '0')
  441. }
  442. b = strconv.AppendInt(b, int64(t.Second()), 10)
  443. return string(b)
  444. }
  445. // FmtTimeLong returns the long time representation of 't' for 'it_CH'
  446. func (it *it_CH) FmtTimeLong(t time.Time) string {
  447. b := make([]byte, 0, 32)
  448. if t.Hour() < 10 {
  449. b = append(b, '0')
  450. }
  451. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  452. b = append(b, it.timeSeparator...)
  453. if t.Minute() < 10 {
  454. b = append(b, '0')
  455. }
  456. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  457. b = append(b, it.timeSeparator...)
  458. if t.Second() < 10 {
  459. b = append(b, '0')
  460. }
  461. b = strconv.AppendInt(b, int64(t.Second()), 10)
  462. b = append(b, []byte{0x20}...)
  463. tz, _ := t.Zone()
  464. b = append(b, tz...)
  465. return string(b)
  466. }
  467. // FmtTimeFull returns the full time representation of 't' for 'it_CH'
  468. func (it *it_CH) FmtTimeFull(t time.Time) string {
  469. b := make([]byte, 0, 32)
  470. if t.Hour() < 10 {
  471. b = append(b, '0')
  472. }
  473. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  474. b = append(b, it.timeSeparator...)
  475. if t.Minute() < 10 {
  476. b = append(b, '0')
  477. }
  478. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  479. b = append(b, it.timeSeparator...)
  480. if t.Second() < 10 {
  481. b = append(b, '0')
  482. }
  483. b = strconv.AppendInt(b, int64(t.Second()), 10)
  484. b = append(b, []byte{0x20}...)
  485. tz, _ := t.Zone()
  486. if btz, ok := it.timezones[tz]; ok {
  487. b = append(b, btz...)
  488. } else {
  489. b = append(b, tz...)
  490. }
  491. return string(b)
  492. }