gsw_CH.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. package gsw_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 gsw_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. percentSuffix string
  19. perMille string
  20. timeSeparator string
  21. inifinity string
  22. currencies []string // idx = enum of currency code
  23. currencyPositiveSuffix string
  24. currencyNegativeSuffix string
  25. monthsAbbreviated []string
  26. monthsNarrow []string
  27. monthsWide []string
  28. daysAbbreviated []string
  29. daysNarrow []string
  30. daysShort []string
  31. daysWide []string
  32. periodsAbbreviated []string
  33. periodsNarrow []string
  34. periodsShort []string
  35. periodsWide []string
  36. erasAbbreviated []string
  37. erasNarrow []string
  38. erasWide []string
  39. timezones map[string]string
  40. }
  41. // New returns a new instance of translator for the 'gsw_CH' locale
  42. func New() locales.Translator {
  43. return &gsw_CH{
  44. locale: "gsw_CH",
  45. pluralsCardinal: []locales.PluralRule{2, 6},
  46. pluralsOrdinal: []locales.PluralRule{6},
  47. pluralsRange: []locales.PluralRule{2, 6},
  48. decimal: ".",
  49. group: "’",
  50. minus: "−",
  51. percent: "%",
  52. perMille: "‰",
  53. timeSeparator: ":",
  54. inifinity: "∞",
  55. 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"},
  56. percentSuffix: " ",
  57. currencyPositiveSuffix: " ",
  58. currencyNegativeSuffix: " ",
  59. monthsAbbreviated: []string{"", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"},
  60. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  61. monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "Auguscht", "Septämber", "Oktoober", "Novämber", "Dezämber"},
  62. daysAbbreviated: []string{"Su.", "Mä.", "Zi.", "Mi.", "Du.", "Fr.", "Sa."},
  63. daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"},
  64. daysWide: []string{"Sunntig", "Määntig", "Ziischtig", "Mittwuch", "Dunschtig", "Friitig", "Samschtig"},
  65. periodsAbbreviated: []string{"vorm.", "nam."},
  66. periodsWide: []string{"am Vormittag", "am Namittag"},
  67. erasAbbreviated: []string{"v. Chr.", "n. Chr."},
  68. erasNarrow: []string{"v. Chr.", "n. Chr."},
  69. erasWide: []string{"v. Chr.", "n. Chr."},
  70. timezones: map[string]string{"MEZ": "Mitteleuropäischi Schtandardziit", "LHST": "LHST", "LHDT": "LHDT", "VET": "VET", "COST": "COST", "PST": "PST", "JDT": "JDT", "ACST": "ACST", "HENOMX": "HENOMX", "CAT": "Zentralafrikanischi Ziit", "CHADT": "CHADT", "WIB": "WIB", "ACWST": "ACWST", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "ART": "ART", "COT": "COT", "WARST": "WARST", "AEST": "AEST", "AST": "AST", "WITA": "WITA", "WIT": "WIT", "HNCU": "HNCU", "ADT": "ADT", "SAST": "Süüdafrikanischi ziit", "NZST": "NZST", "HEEG": "HEEG", "HNOG": "HNOG", "ARST": "ARST", "ChST": "ChST", "AWDT": "AWDT", "GFT": "GFT", "ECT": "ECT", "HAST": "HAST", "UYST": "UYST", "GMT": "GMT", "WEZ": "Weschteuropäischi Schtandardziit", "∅∅∅": "Acre-Summerziit", "BT": "BT", "SGT": "SGT", "EST": "EST", "WART": "WART", "HECU": "HECU", "MYT": "MYT", "HKST": "HKST", "MST": "MST", "MDT": "MDT", "PDT": "PDT", "OEZ": "Oschteuropäischi Schtandardziit", "NZDT": "NZDT", "ACWDT": "ACWDT", "HKT": "HKT", "HEPM": "HEPM", "SRT": "SRT", "EAT": "Oschtafrikanischi Ziit", "TMST": "TMST", "OESZ": "Oschteuropäischi Summerziit", "HNPMX": "HNPMX", "CDT": "Amerika-Zentraal Summerziit", "BOT": "BOT", "AKST": "Alaska-Schtandardziit", "TMT": "TMT", "GYT": "GYT", "EDT": "EDT", "HAT": "HAT", "HEPMX": "HEPMX", "CST": "Amerika-Zentraal Schtandardziit", "WAST": "Weschtafrikanischi Summerziit", "JST": "JST", "MESZ": "Mitteleuropäischi Summerziit", "HADT": "HADT", "UYT": "UYT", "WAT": "Weschtafrikanischi Schtandardziit", "ACDT": "ACDT", "CHAST": "CHAST", "AEDT": "AEDT", "CLST": "CLST", "WESZ": "Weschteuropäischi Summerziit", "AKDT": "Alaska-Summerziit", "HEOG": "HEOG", "IST": "IST", "HNPM": "HNPM", "HNT": "HNT", "CLT": "CLT", "AWST": "AWST"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (gsw *gsw_CH) Locale() string {
  75. return gsw.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'gsw_CH'
  78. func (gsw *gsw_CH) PluralsCardinal() []locales.PluralRule {
  79. return gsw.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'gsw_CH'
  82. func (gsw *gsw_CH) PluralsOrdinal() []locales.PluralRule {
  83. return gsw.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'gsw_CH'
  86. func (gsw *gsw_CH) PluralsRange() []locales.PluralRule {
  87. return gsw.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_CH'
  90. func (gsw *gsw_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. if n == 1 {
  93. return locales.PluralRuleOne
  94. }
  95. return locales.PluralRuleOther
  96. }
  97. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_CH'
  98. func (gsw *gsw_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  99. return locales.PluralRuleOther
  100. }
  101. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gsw_CH'
  102. func (gsw *gsw_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  103. start := gsw.CardinalPluralRule(num1, v1)
  104. end := gsw.CardinalPluralRule(num2, v2)
  105. if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  106. return locales.PluralRuleOther
  107. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  108. return locales.PluralRuleOne
  109. }
  110. return locales.PluralRuleOther
  111. }
  112. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  113. func (gsw *gsw_CH) MonthAbbreviated(month time.Month) string {
  114. return gsw.monthsAbbreviated[month]
  115. }
  116. // MonthsAbbreviated returns the locales abbreviated months
  117. func (gsw *gsw_CH) MonthsAbbreviated() []string {
  118. return gsw.monthsAbbreviated[1:]
  119. }
  120. // MonthNarrow returns the locales narrow month given the 'month' provided
  121. func (gsw *gsw_CH) MonthNarrow(month time.Month) string {
  122. return gsw.monthsNarrow[month]
  123. }
  124. // MonthsNarrow returns the locales narrow months
  125. func (gsw *gsw_CH) MonthsNarrow() []string {
  126. return gsw.monthsNarrow[1:]
  127. }
  128. // MonthWide returns the locales wide month given the 'month' provided
  129. func (gsw *gsw_CH) MonthWide(month time.Month) string {
  130. return gsw.monthsWide[month]
  131. }
  132. // MonthsWide returns the locales wide months
  133. func (gsw *gsw_CH) MonthsWide() []string {
  134. return gsw.monthsWide[1:]
  135. }
  136. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  137. func (gsw *gsw_CH) WeekdayAbbreviated(weekday time.Weekday) string {
  138. return gsw.daysAbbreviated[weekday]
  139. }
  140. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  141. func (gsw *gsw_CH) WeekdaysAbbreviated() []string {
  142. return gsw.daysAbbreviated
  143. }
  144. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  145. func (gsw *gsw_CH) WeekdayNarrow(weekday time.Weekday) string {
  146. return gsw.daysNarrow[weekday]
  147. }
  148. // WeekdaysNarrow returns the locales narrow weekdays
  149. func (gsw *gsw_CH) WeekdaysNarrow() []string {
  150. return gsw.daysNarrow
  151. }
  152. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  153. func (gsw *gsw_CH) WeekdayShort(weekday time.Weekday) string {
  154. return gsw.daysShort[weekday]
  155. }
  156. // WeekdaysShort returns the locales short weekdays
  157. func (gsw *gsw_CH) WeekdaysShort() []string {
  158. return gsw.daysShort
  159. }
  160. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  161. func (gsw *gsw_CH) WeekdayWide(weekday time.Weekday) string {
  162. return gsw.daysWide[weekday]
  163. }
  164. // WeekdaysWide returns the locales wide weekdays
  165. func (gsw *gsw_CH) WeekdaysWide() []string {
  166. return gsw.daysWide
  167. }
  168. // Decimal returns the decimal point of number
  169. func (gsw *gsw_CH) Decimal() string {
  170. return gsw.decimal
  171. }
  172. // Group returns the group of number
  173. func (gsw *gsw_CH) Group() string {
  174. return gsw.group
  175. }
  176. // Group returns the minus sign of number
  177. func (gsw *gsw_CH) Minus() string {
  178. return gsw.minus
  179. }
  180. // FmtNumber returns 'num' with digits/precision of 'v' for 'gsw_CH' and handles both Whole and Real numbers based on 'v'
  181. func (gsw *gsw_CH) FmtNumber(num float64, v uint64) string {
  182. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  183. l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3
  184. count := 0
  185. inWhole := v == 0
  186. b := make([]byte, 0, l)
  187. for i := len(s) - 1; i >= 0; i-- {
  188. if s[i] == '.' {
  189. b = append(b, gsw.decimal[0])
  190. inWhole = true
  191. continue
  192. }
  193. if inWhole {
  194. if count == 3 {
  195. for j := len(gsw.group) - 1; j >= 0; j-- {
  196. b = append(b, gsw.group[j])
  197. }
  198. count = 1
  199. } else {
  200. count++
  201. }
  202. }
  203. b = append(b, s[i])
  204. }
  205. if num < 0 {
  206. for j := len(gsw.minus) - 1; j >= 0; j-- {
  207. b = append(b, gsw.minus[j])
  208. }
  209. }
  210. // reverse
  211. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  212. b[i], b[j] = b[j], b[i]
  213. }
  214. return string(b)
  215. }
  216. // FmtPercent returns 'num' with digits/precision of 'v' for 'gsw_CH' and handles both Whole and Real numbers based on 'v'
  217. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  218. func (gsw *gsw_CH) FmtPercent(num float64, v uint64) string {
  219. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  220. l := len(s) + 7
  221. b := make([]byte, 0, l)
  222. for i := len(s) - 1; i >= 0; i-- {
  223. if s[i] == '.' {
  224. b = append(b, gsw.decimal[0])
  225. continue
  226. }
  227. b = append(b, s[i])
  228. }
  229. if num < 0 {
  230. for j := len(gsw.minus) - 1; j >= 0; j-- {
  231. b = append(b, gsw.minus[j])
  232. }
  233. }
  234. // reverse
  235. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  236. b[i], b[j] = b[j], b[i]
  237. }
  238. b = append(b, gsw.percentSuffix...)
  239. b = append(b, gsw.percent...)
  240. return string(b)
  241. }
  242. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_CH'
  243. func (gsw *gsw_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  244. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  245. symbol := gsw.currencies[currency]
  246. l := len(s) + len(symbol) + 6 + 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, gsw.decimal[0])
  253. inWhole = true
  254. continue
  255. }
  256. if inWhole {
  257. if count == 3 {
  258. for j := len(gsw.group) - 1; j >= 0; j-- {
  259. b = append(b, gsw.group[j])
  260. }
  261. count = 1
  262. } else {
  263. count++
  264. }
  265. }
  266. b = append(b, s[i])
  267. }
  268. if num < 0 {
  269. for j := len(gsw.minus) - 1; j >= 0; j-- {
  270. b = append(b, gsw.minus[j])
  271. }
  272. }
  273. // reverse
  274. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  275. b[i], b[j] = b[j], b[i]
  276. }
  277. if int(v) < 2 {
  278. if v == 0 {
  279. b = append(b, gsw.decimal...)
  280. }
  281. for i := 0; i < 2-int(v); i++ {
  282. b = append(b, '0')
  283. }
  284. }
  285. b = append(b, gsw.currencyPositiveSuffix...)
  286. b = append(b, symbol...)
  287. return string(b)
  288. }
  289. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_CH'
  290. // in accounting notation.
  291. func (gsw *gsw_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  292. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  293. symbol := gsw.currencies[currency]
  294. l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3
  295. count := 0
  296. inWhole := v == 0
  297. b := make([]byte, 0, l)
  298. for i := len(s) - 1; i >= 0; i-- {
  299. if s[i] == '.' {
  300. b = append(b, gsw.decimal[0])
  301. inWhole = true
  302. continue
  303. }
  304. if inWhole {
  305. if count == 3 {
  306. for j := len(gsw.group) - 1; j >= 0; j-- {
  307. b = append(b, gsw.group[j])
  308. }
  309. count = 1
  310. } else {
  311. count++
  312. }
  313. }
  314. b = append(b, s[i])
  315. }
  316. if num < 0 {
  317. for j := len(gsw.minus) - 1; j >= 0; j-- {
  318. b = append(b, gsw.minus[j])
  319. }
  320. }
  321. // reverse
  322. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  323. b[i], b[j] = b[j], b[i]
  324. }
  325. if int(v) < 2 {
  326. if v == 0 {
  327. b = append(b, gsw.decimal...)
  328. }
  329. for i := 0; i < 2-int(v); i++ {
  330. b = append(b, '0')
  331. }
  332. }
  333. if num < 0 {
  334. b = append(b, gsw.currencyNegativeSuffix...)
  335. b = append(b, symbol...)
  336. } else {
  337. b = append(b, gsw.currencyPositiveSuffix...)
  338. b = append(b, symbol...)
  339. }
  340. return string(b)
  341. }
  342. // FmtDateShort returns the short date representation of 't' for 'gsw_CH'
  343. func (gsw *gsw_CH) FmtDateShort(t time.Time) string {
  344. b := make([]byte, 0, 32)
  345. if t.Day() < 10 {
  346. b = append(b, '0')
  347. }
  348. b = strconv.AppendInt(b, int64(t.Day()), 10)
  349. b = append(b, []byte{0x2e}...)
  350. if t.Month() < 10 {
  351. b = append(b, '0')
  352. }
  353. b = strconv.AppendInt(b, int64(t.Month()), 10)
  354. b = append(b, []byte{0x2e}...)
  355. if t.Year() > 9 {
  356. b = append(b, strconv.Itoa(t.Year())[2:]...)
  357. } else {
  358. b = append(b, strconv.Itoa(t.Year())[1:]...)
  359. }
  360. return string(b)
  361. }
  362. // FmtDateMedium returns the medium date representation of 't' for 'gsw_CH'
  363. func (gsw *gsw_CH) FmtDateMedium(t time.Time) string {
  364. b := make([]byte, 0, 32)
  365. if t.Day() < 10 {
  366. b = append(b, '0')
  367. }
  368. b = strconv.AppendInt(b, int64(t.Day()), 10)
  369. b = append(b, []byte{0x2e}...)
  370. if t.Month() < 10 {
  371. b = append(b, '0')
  372. }
  373. b = strconv.AppendInt(b, int64(t.Month()), 10)
  374. b = append(b, []byte{0x2e}...)
  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 'gsw_CH'
  383. func (gsw *gsw_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{0x2e, 0x20}...)
  387. b = append(b, gsw.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 'gsw_CH'
  397. func (gsw *gsw_CH) FmtDateFull(t time.Time) string {
  398. b := make([]byte, 0, 32)
  399. b = append(b, gsw.daysWide[t.Weekday()]...)
  400. b = append(b, []byte{0x2c, 0x20}...)
  401. b = strconv.AppendInt(b, int64(t.Day()), 10)
  402. b = append(b, []byte{0x2e, 0x20}...)
  403. b = append(b, gsw.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 'gsw_CH'
  413. func (gsw *gsw_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, gsw.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 'gsw_CH'
  427. func (gsw *gsw_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, gsw.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, gsw.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 'gsw_CH'
  446. func (gsw *gsw_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, gsw.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, gsw.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 'gsw_CH'
  468. func (gsw *gsw_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, gsw.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, gsw.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 := gsw.timezones[tz]; ok {
  487. b = append(b, btz...)
  488. } else {
  489. b = append(b, tz...)
  490. }
  491. return string(b)
  492. }