fr_CH.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. package fr_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 fr_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 'fr_CH' locale
  41. func New() locales.Translator {
  42. return &fr_CH{
  43. locale: "fr_CH",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{2, 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 ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "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 ", "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{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."},
  58. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  59. monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"},
  60. daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."},
  61. daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"},
  62. daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"},
  63. daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"AM", "PM"},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."},
  68. erasNarrow: []string{"av. J.-C.", "ap. J.-C."},
  69. erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"},
  70. timezones: map[string]string{"OEZ": "heure normale d’Europe de l’Est", "HNT": "heure normale de Terre-Neuve", "AWST": "heure normale de l’Ouest de l’Australie", "LHST": "heure normale de Lord Howe", "LHDT": "heure d’été de Lord Howe", "AEDT": "heure d’été de l’Est de l’Australie", "HAT": "heure d’été de Terre-Neuve", "WESZ": "heure d’été d’Europe de l’Ouest", "MDT": "heure d’été des Rocheuses", "COST": "heure d’été de Colombie", "OESZ": "heure d’été d’Europe de l’Est", "GFT": "heure de la Guyane française", "ACST": "heure normale du centre de l’Australie", "ADT": "heure d’été de l’Atlantique", "WAST": "heure d’été d’Afrique de l’Ouest", "PST": "heure normale du Pacifique nord-américain", "ACWST": "heure normale du centre-ouest de l’Australie", "EST": "heure normale de l’Est nord-américain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "WAT": "heure normale d’Afrique de l’Ouest", "GMT": "heure moyenne de Greenwich", "GYT": "heure du Guyana", "MYT": "heure de la Malaisie", "EDT": "heure d’été de l’Est", "HKT": "heure normale de Hong Kong", "WART": "heure normale de l’Ouest argentin", "WIB": "heure de l’Ouest indonésien", "JDT": "heure d’été du Japon", "AKDT": "heure d’été de l’Alaska", "CLST": "heure d’été du Chili", "CAT": "heure normale d’Afrique centrale", "ECT": "heure de l’Équateur", "WIT": "heure de l’Est indonésien", "WITA": "heure du Centre indonésien", "ART": "heure normale d’Argentine", "JST": "heure normale du Japon", "AWDT": "heure d’été de l’Ouest de l’Australie", "BT": "heure du Bhoutan", "EAT": "heure normale d’Afrique de l’Est", "TMST": "heure d’été du Turkménistan", "CDT": "heure d’été du Centre", "MEZ": "heure normale d’Europe centrale", "NZST": "heure normale de la Nouvelle-Zélande", "UYT": "heure normale de l’Uruguay", "CLT": "heure normale du Chili", "SAST": "heure normale d’Afrique méridionale", "TMT": "heure normale du Turkménistan", "NZDT": "heure d’été de la Nouvelle-Zélande", "AEST": "heure normale de l’Est de l’Australie", "HKST": "heure d’été de Hong Kong", "IST": "heure de l’Inde", "AKST": "heure normale de l’Alaska", "PDT": "heure d’été du Pacifique", "WARST": "heure d’été de l’Ouest argentin", "CST": "heure normale du centre nord-américain", "VET": "heure du Venezuela", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MST": "heure normale des Rocheuses", "COT": "heure normale de Colombie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "BOT": "heure de Bolivie", "UYST": "heure d’été de l’Uruguay", "ChST": "heure des Chamorro", "ACDT": "heure d’été du centre de l’Australie", "SRT": "heure du Suriname", "MESZ": "heure d’été d’Europe centrale", "CHAST": "heure normale des îles Chatham", "AST": "heure normale de l’Atlantique", "SGT": "heure de Singapour", "ARST": "heure d’été de l’Argentine", "∅∅∅": "heure d’été des Açores", "WEZ": "heure normale d’Europe de l’Ouest", "CHADT": "heure d’été des îles Chatham"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (fr *fr_CH) Locale() string {
  75. return fr.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CH'
  78. func (fr *fr_CH) PluralsCardinal() []locales.PluralRule {
  79. return fr.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CH'
  82. func (fr *fr_CH) PluralsOrdinal() []locales.PluralRule {
  83. return fr.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'fr_CH'
  86. func (fr *fr_CH) PluralsRange() []locales.PluralRule {
  87. return fr.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CH'
  90. func (fr *fr_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. if i == 0 || i == 1 {
  94. return locales.PluralRuleOne
  95. }
  96. return locales.PluralRuleOther
  97. }
  98. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CH'
  99. func (fr *fr_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  100. n := math.Abs(num)
  101. if n == 1 {
  102. return locales.PluralRuleOne
  103. }
  104. return locales.PluralRuleOther
  105. }
  106. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CH'
  107. func (fr *fr_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  108. start := fr.CardinalPluralRule(num1, v1)
  109. end := fr.CardinalPluralRule(num2, v2)
  110. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  111. return locales.PluralRuleOne
  112. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  113. return locales.PluralRuleOther
  114. }
  115. return locales.PluralRuleOther
  116. }
  117. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  118. func (fr *fr_CH) MonthAbbreviated(month time.Month) string {
  119. return fr.monthsAbbreviated[month]
  120. }
  121. // MonthsAbbreviated returns the locales abbreviated months
  122. func (fr *fr_CH) MonthsAbbreviated() []string {
  123. return fr.monthsAbbreviated[1:]
  124. }
  125. // MonthNarrow returns the locales narrow month given the 'month' provided
  126. func (fr *fr_CH) MonthNarrow(month time.Month) string {
  127. return fr.monthsNarrow[month]
  128. }
  129. // MonthsNarrow returns the locales narrow months
  130. func (fr *fr_CH) MonthsNarrow() []string {
  131. return fr.monthsNarrow[1:]
  132. }
  133. // MonthWide returns the locales wide month given the 'month' provided
  134. func (fr *fr_CH) MonthWide(month time.Month) string {
  135. return fr.monthsWide[month]
  136. }
  137. // MonthsWide returns the locales wide months
  138. func (fr *fr_CH) MonthsWide() []string {
  139. return fr.monthsWide[1:]
  140. }
  141. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  142. func (fr *fr_CH) WeekdayAbbreviated(weekday time.Weekday) string {
  143. return fr.daysAbbreviated[weekday]
  144. }
  145. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  146. func (fr *fr_CH) WeekdaysAbbreviated() []string {
  147. return fr.daysAbbreviated
  148. }
  149. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  150. func (fr *fr_CH) WeekdayNarrow(weekday time.Weekday) string {
  151. return fr.daysNarrow[weekday]
  152. }
  153. // WeekdaysNarrow returns the locales narrow weekdays
  154. func (fr *fr_CH) WeekdaysNarrow() []string {
  155. return fr.daysNarrow
  156. }
  157. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  158. func (fr *fr_CH) WeekdayShort(weekday time.Weekday) string {
  159. return fr.daysShort[weekday]
  160. }
  161. // WeekdaysShort returns the locales short weekdays
  162. func (fr *fr_CH) WeekdaysShort() []string {
  163. return fr.daysShort
  164. }
  165. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  166. func (fr *fr_CH) WeekdayWide(weekday time.Weekday) string {
  167. return fr.daysWide[weekday]
  168. }
  169. // WeekdaysWide returns the locales wide weekdays
  170. func (fr *fr_CH) WeekdaysWide() []string {
  171. return fr.daysWide
  172. }
  173. // FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CH' and handles both Whole and Real numbers based on 'v'
  174. func (fr *fr_CH) FmtNumber(num float64, v uint64) string {
  175. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  176. l := len(s) + 7 + 2*len(s[:len(s)-int(v)-1])/3
  177. count := 0
  178. inWhole := v == 0
  179. b := make([]byte, 0, l)
  180. for i := len(s) - 1; i >= 0; i-- {
  181. if s[i] == '.' {
  182. b = append(b, fr.decimal[0])
  183. inWhole = true
  184. continue
  185. }
  186. if inWhole {
  187. if count == 3 {
  188. for j := len(fr.group) - 1; j >= 0; j-- {
  189. b = append(b, fr.group[j])
  190. }
  191. count = 1
  192. } else {
  193. count++
  194. }
  195. }
  196. b = append(b, s[i])
  197. }
  198. if num < 0 {
  199. for j := len(fr.minus) - 1; j >= 0; j-- {
  200. b = append(b, fr.minus[j])
  201. }
  202. }
  203. // reverse
  204. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  205. b[i], b[j] = b[j], b[i]
  206. }
  207. return string(b)
  208. }
  209. // FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CH' and handles both Whole and Real numbers based on 'v'
  210. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  211. func (fr *fr_CH) FmtPercent(num float64, v uint64) string {
  212. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  213. l := len(s) + 9
  214. b := make([]byte, 0, l)
  215. for i := len(s) - 1; i >= 0; i-- {
  216. if s[i] == '.' {
  217. b = append(b, fr.decimal[0])
  218. continue
  219. }
  220. b = append(b, s[i])
  221. }
  222. if num < 0 {
  223. for j := len(fr.minus) - 1; j >= 0; j-- {
  224. b = append(b, fr.minus[j])
  225. }
  226. }
  227. // reverse
  228. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  229. b[i], b[j] = b[j], b[i]
  230. }
  231. b = append(b, fr.percent...)
  232. return string(b)
  233. }
  234. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CH'
  235. func (fr *fr_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  236. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  237. symbol := fr.currencies[currency]
  238. l := len(s) + len(symbol) + 9 + 2*len(s[:len(s)-int(v)-1])/3
  239. count := 0
  240. inWhole := v == 0
  241. b := make([]byte, 0, l)
  242. for i := len(s) - 1; i >= 0; i-- {
  243. if s[i] == '.' {
  244. b = append(b, fr.decimal[0])
  245. inWhole = true
  246. continue
  247. }
  248. if inWhole {
  249. if count == 3 {
  250. for j := len(fr.group) - 1; j >= 0; j-- {
  251. b = append(b, fr.group[j])
  252. }
  253. count = 1
  254. } else {
  255. count++
  256. }
  257. }
  258. b = append(b, s[i])
  259. }
  260. for j := len(symbol) - 1; j >= 0; j-- {
  261. b = append(b, symbol[j])
  262. }
  263. for j := len(fr.currencyPositivePrefix) - 1; j >= 0; j-- {
  264. b = append(b, fr.currencyPositivePrefix[j])
  265. }
  266. if num < 0 {
  267. for j := len(fr.minus) - 1; j >= 0; j-- {
  268. b = append(b, fr.minus[j])
  269. }
  270. }
  271. // reverse
  272. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  273. b[i], b[j] = b[j], b[i]
  274. }
  275. if int(v) < 2 {
  276. if v == 0 {
  277. b = append(b, fr.decimal...)
  278. }
  279. for i := 0; i < 2-int(v); i++ {
  280. b = append(b, '0')
  281. }
  282. }
  283. return string(b)
  284. }
  285. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CH'
  286. // in accounting notation.
  287. func (fr *fr_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  288. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  289. symbol := fr.currencies[currency]
  290. l := len(s) + len(symbol) + 9 + 2*len(s[:len(s)-int(v)-1])/3
  291. count := 0
  292. inWhole := v == 0
  293. b := make([]byte, 0, l)
  294. for i := len(s) - 1; i >= 0; i-- {
  295. if s[i] == '.' {
  296. b = append(b, fr.decimal[0])
  297. inWhole = true
  298. continue
  299. }
  300. if inWhole {
  301. if count == 3 {
  302. for j := len(fr.group) - 1; j >= 0; j-- {
  303. b = append(b, fr.group[j])
  304. }
  305. count = 1
  306. } else {
  307. count++
  308. }
  309. }
  310. b = append(b, s[i])
  311. }
  312. if num < 0 {
  313. for j := len(symbol) - 1; j >= 0; j-- {
  314. b = append(b, symbol[j])
  315. }
  316. for j := len(fr.currencyNegativePrefix) - 1; j >= 0; j-- {
  317. b = append(b, fr.currencyNegativePrefix[j])
  318. }
  319. for j := len(fr.minus) - 1; j >= 0; j-- {
  320. b = append(b, fr.minus[j])
  321. }
  322. } else {
  323. for j := len(symbol) - 1; j >= 0; j-- {
  324. b = append(b, symbol[j])
  325. }
  326. for j := len(fr.currencyPositivePrefix) - 1; j >= 0; j-- {
  327. b = append(b, fr.currencyPositivePrefix[j])
  328. }
  329. }
  330. // reverse
  331. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  332. b[i], b[j] = b[j], b[i]
  333. }
  334. if int(v) < 2 {
  335. if v == 0 {
  336. b = append(b, fr.decimal...)
  337. }
  338. for i := 0; i < 2-int(v); i++ {
  339. b = append(b, '0')
  340. }
  341. }
  342. return string(b)
  343. }
  344. // FmtDateShort returns the short date representation of 't' for 'fr_CH'
  345. func (fr *fr_CH) FmtDateShort(t time.Time) string {
  346. b := make([]byte, 0, 32)
  347. if t.Day() < 10 {
  348. b = append(b, '0')
  349. }
  350. b = strconv.AppendInt(b, int64(t.Day()), 10)
  351. b = append(b, []byte{0x2e}...)
  352. if t.Month() < 10 {
  353. b = append(b, '0')
  354. }
  355. b = strconv.AppendInt(b, int64(t.Month()), 10)
  356. b = append(b, []byte{0x2e}...)
  357. if t.Year() > 9 {
  358. b = append(b, strconv.Itoa(t.Year())[2:]...)
  359. } else {
  360. b = append(b, strconv.Itoa(t.Year())[1:]...)
  361. }
  362. return string(b)
  363. }
  364. // FmtDateMedium returns the medium date representation of 't' for 'fr_CH'
  365. func (fr *fr_CH) FmtDateMedium(t time.Time) string {
  366. b := make([]byte, 0, 32)
  367. b = strconv.AppendInt(b, int64(t.Day()), 10)
  368. b = append(b, []byte{0x20}...)
  369. b = append(b, fr.monthsAbbreviated[t.Month()]...)
  370. b = append(b, []byte{0x20}...)
  371. b = strconv.AppendInt(b, int64(t.Year()), 10)
  372. return string(b)
  373. }
  374. // FmtDateLong returns the long date representation of 't' for 'fr_CH'
  375. func (fr *fr_CH) FmtDateLong(t time.Time) string {
  376. b := make([]byte, 0, 32)
  377. b = strconv.AppendInt(b, int64(t.Day()), 10)
  378. b = append(b, []byte{0x20}...)
  379. b = append(b, fr.monthsWide[t.Month()]...)
  380. b = append(b, []byte{0x20}...)
  381. b = strconv.AppendInt(b, int64(t.Year()), 10)
  382. return string(b)
  383. }
  384. // FmtDateFull returns the full date representation of 't' for 'fr_CH'
  385. func (fr *fr_CH) FmtDateFull(t time.Time) string {
  386. b := make([]byte, 0, 32)
  387. b = append(b, fr.daysWide[t.Weekday()]...)
  388. b = append(b, []byte{0x2c, 0x20}...)
  389. b = strconv.AppendInt(b, int64(t.Day()), 10)
  390. b = append(b, []byte{0x20}...)
  391. b = append(b, fr.monthsWide[t.Month()]...)
  392. b = append(b, []byte{0x20}...)
  393. b = strconv.AppendInt(b, int64(t.Year()), 10)
  394. return string(b)
  395. }
  396. // FmtTimeShort returns the short time representation of 't' for 'fr_CH'
  397. func (fr *fr_CH) FmtTimeShort(t time.Time) string {
  398. b := make([]byte, 0, 32)
  399. if t.Hour() < 10 {
  400. b = append(b, '0')
  401. }
  402. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  403. b = append(b, fr.timeSeparator...)
  404. if t.Minute() < 10 {
  405. b = append(b, '0')
  406. }
  407. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  408. return string(b)
  409. }
  410. // FmtTimeMedium returns the medium time representation of 't' for 'fr_CH'
  411. func (fr *fr_CH) FmtTimeMedium(t time.Time) string {
  412. b := make([]byte, 0, 32)
  413. if t.Hour() < 10 {
  414. b = append(b, '0')
  415. }
  416. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  417. b = append(b, fr.timeSeparator...)
  418. if t.Minute() < 10 {
  419. b = append(b, '0')
  420. }
  421. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  422. b = append(b, fr.timeSeparator...)
  423. if t.Second() < 10 {
  424. b = append(b, '0')
  425. }
  426. b = strconv.AppendInt(b, int64(t.Second()), 10)
  427. return string(b)
  428. }
  429. // FmtTimeLong returns the long time representation of 't' for 'fr_CH'
  430. func (fr *fr_CH) FmtTimeLong(t time.Time) string {
  431. b := make([]byte, 0, 32)
  432. if t.Hour() < 10 {
  433. b = append(b, '0')
  434. }
  435. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  436. b = append(b, fr.timeSeparator...)
  437. if t.Minute() < 10 {
  438. b = append(b, '0')
  439. }
  440. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  441. b = append(b, fr.timeSeparator...)
  442. if t.Second() < 10 {
  443. b = append(b, '0')
  444. }
  445. b = strconv.AppendInt(b, int64(t.Second()), 10)
  446. b = append(b, []byte{0x20}...)
  447. tz, _ := t.Zone()
  448. b = append(b, tz...)
  449. return string(b)
  450. }
  451. // FmtTimeFull returns the full time representation of 't' for 'fr_CH'
  452. func (fr *fr_CH) FmtTimeFull(t time.Time) string {
  453. b := make([]byte, 0, 32)
  454. if t.Hour() < 10 {
  455. b = append(b, '0')
  456. }
  457. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  458. b = append(b, []byte{0x2e}...)
  459. if t.Minute() < 10 {
  460. b = append(b, '0')
  461. }
  462. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  463. b = append(b, fr.timeSeparator...)
  464. if t.Second() < 10 {
  465. b = append(b, '0')
  466. }
  467. b = strconv.AppendInt(b, int64(t.Second()), 10)
  468. b = append(b, []byte{}...)
  469. b = append(b, []byte{0x27, 0x68, 0x27, 0x20}...)
  470. tz, _ := t.Zone()
  471. if btz, ok := fr.timezones[tz]; ok {
  472. b = append(b, btz...)
  473. } else {
  474. b = append(b, tz...)
  475. }
  476. return string(b)
  477. }