...

Source file src/github.com/go-playground/locales/it_CH/it_CH.go

Documentation: github.com/go-playground/locales/it_CH

     1  package it_CH
     2  
     3  import (
     4  	"math"
     5  	"strconv"
     6  	"time"
     7  
     8  	"github.com/go-playground/locales"
     9  	"github.com/go-playground/locales/currency"
    10  )
    11  
    12  type it_CH struct {
    13  	locale                 string
    14  	pluralsCardinal        []locales.PluralRule
    15  	pluralsOrdinal         []locales.PluralRule
    16  	pluralsRange           []locales.PluralRule
    17  	decimal                string
    18  	group                  string
    19  	minus                  string
    20  	percent                string
    21  	perMille               string
    22  	timeSeparator          string
    23  	inifinity              string
    24  	currencies             []string // idx = enum of currency code
    25  	currencyPositivePrefix string
    26  	currencyNegativePrefix string
    27  	monthsAbbreviated      []string
    28  	monthsNarrow           []string
    29  	monthsWide             []string
    30  	daysAbbreviated        []string
    31  	daysNarrow             []string
    32  	daysShort              []string
    33  	daysWide               []string
    34  	periodsAbbreviated     []string
    35  	periodsNarrow          []string
    36  	periodsShort           []string
    37  	periodsWide            []string
    38  	erasAbbreviated        []string
    39  	erasNarrow             []string
    40  	erasWide               []string
    41  	timezones              map[string]string
    42  }
    43  
    44  // New returns a new instance of translator for the 'it_CH' locale
    45  func New() locales.Translator {
    46  	return &it_CH{
    47  		locale:                 "it_CH",
    48  		pluralsCardinal:        []locales.PluralRule{2, 6},
    49  		pluralsOrdinal:         []locales.PluralRule{5, 6},
    50  		pluralsRange:           []locales.PluralRule{2, 6},
    51  		decimal:                ".",
    52  		group:                  "’",
    53  		minus:                  "-",
    54  		percent:                "%",
    55  		perMille:               "‰",
    56  		timeSeparator:          ":",
    57  		inifinity:              "∞",
    58  		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", "MRU", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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"},
    59  		currencyPositivePrefix: " ",
    60  		currencyNegativePrefix: " ",
    61  		monthsAbbreviated:      []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"},
    62  		monthsNarrow:           []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"},
    63  		monthsWide:             []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"},
    64  		daysAbbreviated:        []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
    65  		daysNarrow:             []string{"D", "L", "M", "M", "G", "V", "S"},
    66  		daysShort:              []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
    67  		daysWide:               []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"},
    68  		periodsAbbreviated:     []string{"AM", "PM"},
    69  		periodsNarrow:          []string{"m.", "p."},
    70  		periodsWide:            []string{"AM", "PM"},
    71  		erasAbbreviated:        []string{"a.C.", "d.C."},
    72  		erasNarrow:             []string{"aC", "dC"},
    73  		erasWide:               []string{"avanti Cristo", "dopo Cristo"},
    74  		timezones:              map[string]string{"ACDT": "Ora legale dell’Australia centrale", "ACST": "Ora standard dell’Australia centrale", "ACWDT": "Ora legale dell’Australia centroccidentale", "ACWST": "Ora standard dell’Australia centroccidentale", "ADT": "Ora legale dell’Atlantico", "AEDT": "Ora legale dell’Australia orientale", "AEST": "Ora standard dell’Australia orientale", "AKDT": "Ora legale dell’Alaska", "AKST": "Ora standard dell’Alaska", "ARST": "Ora legale dell’Argentina", "ART": "Ora standard dell’Argentina", "AST": "Ora standard dell’Atlantico", "AWDT": "Ora legale dell’Australia occidentale", "AWST": "Ora standard dell’Australia occidentale", "BOT": "Ora della Bolivia", "BT": "Ora del Bhutan", "CAT": "Ora dell’Africa centrale", "CDT": "Ora legale centrale USA", "CHADT": "Ora legale delle Chatham", "CHAST": "Ora standard delle Chatham", "CLST": "Ora legale del Cile", "CLT": "Ora standard del Cile", "COST": "Ora legale della Colombia", "COT": "Ora standard della Colombia", "CST": "Ora standard centrale USA", "ChST": "Ora di Chamorro", "EAT": "Ora dell’Africa orientale", "ECT": "Ora dell’Ecuador", "EDT": "Ora legale orientale USA", "EST": "Ora standard orientale USA", "GFT": "Ora della Guiana francese", "GMT": "Ora del meridiano di Greenwich", "GST": "Ora del Golfo", "GYT": "Ora della Guyana", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "HAT": "Ora legale di Terranova", "HECU": "Ora legale di Cuba", "HEEG": "Ora legale della Groenlandia orientale", "HENOMX": "Ora legale del Messico nord-occidentale", "HEOG": "Ora legale della Groenlandia occidentale", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "HEPMX": "Ora legale del Pacifico (Messico)", "HKST": "Ora legale di Hong Kong", "HKT": "Ora standard di Hong Kong", "HNCU": "Ora standard di Cuba", "HNEG": "Ora standard della Groenlandia orientale", "HNNOMX": "Ora standard del Messico nord-occidentale", "HNOG": "Ora standard della Groenlandia occidentale", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "HNPMX": "Ora standard del Pacifico (Messico)", "HNT": "Ora standard di Terranova", "IST": "Ora standard dell’India", "JDT": "Ora legale del Giappone", "JST": "Ora standard del Giappone", "LHDT": "Ora legale di Lord Howe", "LHST": "Ora standard di Lord Howe", "MDT": "Ora legale Montagne Rocciose USA", "MESZ": "Ora legale dell’Europa centrale", "MEZ": "Ora standard dell’Europa centrale", "MST": "Ora standard Montagne Rocciose USA", "MYT": "Ora della Malesia", "NZDT": "Ora legale della Nuova Zelanda", "NZST": "Ora standard della Nuova Zelanda", "OESZ": "Ora legale dell’Europa orientale", "OEZ": "Ora standard dell’Europa orientale", "PDT": "Ora legale del Pacifico USA", "PST": "Ora standard del Pacifico USA", "SAST": "Ora dell’Africa meridionale", "SGT": "Ora di Singapore", "SRT": "Ora del Suriname", "TMST": "Ora legale del Turkmenistan", "TMT": "Ora standard del Turkmenistan", "UYST": "Ora legale dell’Uruguay", "UYT": "Ora standard dell’Uruguay", "VET": "Ora del Venezuela", "WARST": "Ora legale dell’Argentina occidentale", "WART": "Ora standard dell’Argentina occidentale", "WAST": "Ora legale dell’Africa occidentale", "WAT": "Ora standard dell’Africa occidentale", "WESZ": "Ora legale dell’Europa occidentale", "WEZ": "Ora standard dell’Europa occidentale", "WIB": "Ora dell’Indonesia occidentale", "WIT": "Ora dell’Indonesia orientale", "WITA": "Ora dell’Indonesia centrale", "∅∅∅": "Ora legale dell’Amazzonia"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (it *it_CH) Locale() string {
    80  	return it.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'it_CH'
    84  func (it *it_CH) PluralsCardinal() []locales.PluralRule {
    85  	return it.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'it_CH'
    89  func (it *it_CH) PluralsOrdinal() []locales.PluralRule {
    90  	return it.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'it_CH'
    94  func (it *it_CH) PluralsRange() []locales.PluralRule {
    95  	return it.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH'
    99  func (it *it_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  
   101  	n := math.Abs(num)
   102  	i := int64(n)
   103  
   104  	if i == 1 && v == 0 {
   105  		return locales.PluralRuleOne
   106  	}
   107  
   108  	return locales.PluralRuleOther
   109  }
   110  
   111  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH'
   112  func (it *it_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   113  
   114  	n := math.Abs(num)
   115  
   116  	if n == 11 || n == 8 || n == 80 || n == 800 {
   117  		return locales.PluralRuleMany
   118  	}
   119  
   120  	return locales.PluralRuleOther
   121  }
   122  
   123  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_CH'
   124  func (it *it_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   125  
   126  	start := it.CardinalPluralRule(num1, v1)
   127  	end := it.CardinalPluralRule(num2, v2)
   128  
   129  	if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
   130  		return locales.PluralRuleOther
   131  	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
   132  		return locales.PluralRuleOne
   133  	}
   134  
   135  	return locales.PluralRuleOther
   136  
   137  }
   138  
   139  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   140  func (it *it_CH) MonthAbbreviated(month time.Month) string {
   141  	return it.monthsAbbreviated[month]
   142  }
   143  
   144  // MonthsAbbreviated returns the locales abbreviated months
   145  func (it *it_CH) MonthsAbbreviated() []string {
   146  	return it.monthsAbbreviated[1:]
   147  }
   148  
   149  // MonthNarrow returns the locales narrow month given the 'month' provided
   150  func (it *it_CH) MonthNarrow(month time.Month) string {
   151  	return it.monthsNarrow[month]
   152  }
   153  
   154  // MonthsNarrow returns the locales narrow months
   155  func (it *it_CH) MonthsNarrow() []string {
   156  	return it.monthsNarrow[1:]
   157  }
   158  
   159  // MonthWide returns the locales wide month given the 'month' provided
   160  func (it *it_CH) MonthWide(month time.Month) string {
   161  	return it.monthsWide[month]
   162  }
   163  
   164  // MonthsWide returns the locales wide months
   165  func (it *it_CH) MonthsWide() []string {
   166  	return it.monthsWide[1:]
   167  }
   168  
   169  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   170  func (it *it_CH) WeekdayAbbreviated(weekday time.Weekday) string {
   171  	return it.daysAbbreviated[weekday]
   172  }
   173  
   174  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   175  func (it *it_CH) WeekdaysAbbreviated() []string {
   176  	return it.daysAbbreviated
   177  }
   178  
   179  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   180  func (it *it_CH) WeekdayNarrow(weekday time.Weekday) string {
   181  	return it.daysNarrow[weekday]
   182  }
   183  
   184  // WeekdaysNarrow returns the locales narrow weekdays
   185  func (it *it_CH) WeekdaysNarrow() []string {
   186  	return it.daysNarrow
   187  }
   188  
   189  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   190  func (it *it_CH) WeekdayShort(weekday time.Weekday) string {
   191  	return it.daysShort[weekday]
   192  }
   193  
   194  // WeekdaysShort returns the locales short weekdays
   195  func (it *it_CH) WeekdaysShort() []string {
   196  	return it.daysShort
   197  }
   198  
   199  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   200  func (it *it_CH) WeekdayWide(weekday time.Weekday) string {
   201  	return it.daysWide[weekday]
   202  }
   203  
   204  // WeekdaysWide returns the locales wide weekdays
   205  func (it *it_CH) WeekdaysWide() []string {
   206  	return it.daysWide
   207  }
   208  
   209  // Decimal returns the decimal point of number
   210  func (it *it_CH) Decimal() string {
   211  	return it.decimal
   212  }
   213  
   214  // Group returns the group of number
   215  func (it *it_CH) Group() string {
   216  	return it.group
   217  }
   218  
   219  // Group returns the minus sign of number
   220  func (it *it_CH) Minus() string {
   221  	return it.minus
   222  }
   223  
   224  // FmtNumber returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
   225  func (it *it_CH) FmtNumber(num float64, v uint64) string {
   226  
   227  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   228  	l := len(s) + 2 + 3*len(s[:len(s)-int(v)-1])/3
   229  	count := 0
   230  	inWhole := v == 0
   231  	b := make([]byte, 0, l)
   232  
   233  	for i := len(s) - 1; i >= 0; i-- {
   234  
   235  		if s[i] == '.' {
   236  			b = append(b, it.decimal[0])
   237  			inWhole = true
   238  			continue
   239  		}
   240  
   241  		if inWhole {
   242  			if count == 3 {
   243  				for j := len(it.group) - 1; j >= 0; j-- {
   244  					b = append(b, it.group[j])
   245  				}
   246  				count = 1
   247  			} else {
   248  				count++
   249  			}
   250  		}
   251  
   252  		b = append(b, s[i])
   253  	}
   254  
   255  	if num < 0 {
   256  		b = append(b, it.minus[0])
   257  	}
   258  
   259  	// reverse
   260  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   261  		b[i], b[j] = b[j], b[i]
   262  	}
   263  
   264  	return string(b)
   265  }
   266  
   267  // FmtPercent returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
   268  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   269  func (it *it_CH) FmtPercent(num float64, v uint64) string {
   270  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   271  	l := len(s) + 3
   272  	b := make([]byte, 0, l)
   273  
   274  	for i := len(s) - 1; i >= 0; i-- {
   275  
   276  		if s[i] == '.' {
   277  			b = append(b, it.decimal[0])
   278  			continue
   279  		}
   280  
   281  		b = append(b, s[i])
   282  	}
   283  
   284  	if num < 0 {
   285  		b = append(b, it.minus[0])
   286  	}
   287  
   288  	// reverse
   289  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   290  		b[i], b[j] = b[j], b[i]
   291  	}
   292  
   293  	b = append(b, it.percent...)
   294  
   295  	return string(b)
   296  }
   297  
   298  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
   299  func (it *it_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   300  
   301  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   302  	symbol := it.currencies[currency]
   303  	l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
   304  	count := 0
   305  	inWhole := v == 0
   306  	b := make([]byte, 0, l)
   307  
   308  	for i := len(s) - 1; i >= 0; i-- {
   309  
   310  		if s[i] == '.' {
   311  			b = append(b, it.decimal[0])
   312  			inWhole = true
   313  			continue
   314  		}
   315  
   316  		if inWhole {
   317  			if count == 3 {
   318  				for j := len(it.group) - 1; j >= 0; j-- {
   319  					b = append(b, it.group[j])
   320  				}
   321  				count = 1
   322  			} else {
   323  				count++
   324  			}
   325  		}
   326  
   327  		b = append(b, s[i])
   328  	}
   329  
   330  	for j := len(symbol) - 1; j >= 0; j-- {
   331  		b = append(b, symbol[j])
   332  	}
   333  
   334  	for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
   335  		b = append(b, it.currencyPositivePrefix[j])
   336  	}
   337  
   338  	if num < 0 {
   339  		b = append(b, it.minus[0])
   340  	}
   341  
   342  	// reverse
   343  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   344  		b[i], b[j] = b[j], b[i]
   345  	}
   346  
   347  	if int(v) < 2 {
   348  
   349  		if v == 0 {
   350  			b = append(b, it.decimal...)
   351  		}
   352  
   353  		for i := 0; i < 2-int(v); i++ {
   354  			b = append(b, '0')
   355  		}
   356  	}
   357  
   358  	return string(b)
   359  }
   360  
   361  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
   362  // in accounting notation.
   363  func (it *it_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   364  
   365  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   366  	symbol := it.currencies[currency]
   367  	l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
   368  	count := 0
   369  	inWhole := v == 0
   370  	b := make([]byte, 0, l)
   371  
   372  	for i := len(s) - 1; i >= 0; i-- {
   373  
   374  		if s[i] == '.' {
   375  			b = append(b, it.decimal[0])
   376  			inWhole = true
   377  			continue
   378  		}
   379  
   380  		if inWhole {
   381  			if count == 3 {
   382  				for j := len(it.group) - 1; j >= 0; j-- {
   383  					b = append(b, it.group[j])
   384  				}
   385  				count = 1
   386  			} else {
   387  				count++
   388  			}
   389  		}
   390  
   391  		b = append(b, s[i])
   392  	}
   393  
   394  	if num < 0 {
   395  
   396  		for j := len(symbol) - 1; j >= 0; j-- {
   397  			b = append(b, symbol[j])
   398  		}
   399  
   400  		for j := len(it.currencyNegativePrefix) - 1; j >= 0; j-- {
   401  			b = append(b, it.currencyNegativePrefix[j])
   402  		}
   403  
   404  		b = append(b, it.minus[0])
   405  
   406  	} else {
   407  
   408  		for j := len(symbol) - 1; j >= 0; j-- {
   409  			b = append(b, symbol[j])
   410  		}
   411  
   412  		for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
   413  			b = append(b, it.currencyPositivePrefix[j])
   414  		}
   415  
   416  	}
   417  
   418  	// reverse
   419  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   420  		b[i], b[j] = b[j], b[i]
   421  	}
   422  
   423  	if int(v) < 2 {
   424  
   425  		if v == 0 {
   426  			b = append(b, it.decimal...)
   427  		}
   428  
   429  		for i := 0; i < 2-int(v); i++ {
   430  			b = append(b, '0')
   431  		}
   432  	}
   433  
   434  	return string(b)
   435  }
   436  
   437  // FmtDateShort returns the short date representation of 't' for 'it_CH'
   438  func (it *it_CH) FmtDateShort(t time.Time) string {
   439  
   440  	b := make([]byte, 0, 32)
   441  
   442  	if t.Day() < 10 {
   443  		b = append(b, '0')
   444  	}
   445  
   446  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   447  	b = append(b, []byte{0x2e}...)
   448  
   449  	if t.Month() < 10 {
   450  		b = append(b, '0')
   451  	}
   452  
   453  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   454  
   455  	b = append(b, []byte{0x2e}...)
   456  
   457  	if t.Year() > 9 {
   458  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   459  	} else {
   460  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   461  	}
   462  
   463  	return string(b)
   464  }
   465  
   466  // FmtDateMedium returns the medium date representation of 't' for 'it_CH'
   467  func (it *it_CH) FmtDateMedium(t time.Time) string {
   468  
   469  	b := make([]byte, 0, 32)
   470  
   471  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   472  	b = append(b, []byte{0x20}...)
   473  	b = append(b, it.monthsAbbreviated[t.Month()]...)
   474  	b = append(b, []byte{0x20}...)
   475  
   476  	if t.Year() > 0 {
   477  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   478  	} else {
   479  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   480  	}
   481  
   482  	return string(b)
   483  }
   484  
   485  // FmtDateLong returns the long date representation of 't' for 'it_CH'
   486  func (it *it_CH) FmtDateLong(t time.Time) string {
   487  
   488  	b := make([]byte, 0, 32)
   489  
   490  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   491  	b = append(b, []byte{0x20}...)
   492  	b = append(b, it.monthsWide[t.Month()]...)
   493  	b = append(b, []byte{0x20}...)
   494  
   495  	if t.Year() > 0 {
   496  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   497  	} else {
   498  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   499  	}
   500  
   501  	return string(b)
   502  }
   503  
   504  // FmtDateFull returns the full date representation of 't' for 'it_CH'
   505  func (it *it_CH) FmtDateFull(t time.Time) string {
   506  
   507  	b := make([]byte, 0, 32)
   508  
   509  	b = append(b, it.daysWide[t.Weekday()]...)
   510  	b = append(b, []byte{0x2c, 0x20}...)
   511  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   512  	b = append(b, []byte{0x20}...)
   513  	b = append(b, it.monthsWide[t.Month()]...)
   514  	b = append(b, []byte{0x20}...)
   515  
   516  	if t.Year() > 0 {
   517  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   518  	} else {
   519  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   520  	}
   521  
   522  	return string(b)
   523  }
   524  
   525  // FmtTimeShort returns the short time representation of 't' for 'it_CH'
   526  func (it *it_CH) FmtTimeShort(t time.Time) string {
   527  
   528  	b := make([]byte, 0, 32)
   529  
   530  	if t.Hour() < 10 {
   531  		b = append(b, '0')
   532  	}
   533  
   534  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   535  	b = append(b, it.timeSeparator...)
   536  
   537  	if t.Minute() < 10 {
   538  		b = append(b, '0')
   539  	}
   540  
   541  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   542  
   543  	return string(b)
   544  }
   545  
   546  // FmtTimeMedium returns the medium time representation of 't' for 'it_CH'
   547  func (it *it_CH) FmtTimeMedium(t time.Time) string {
   548  
   549  	b := make([]byte, 0, 32)
   550  
   551  	if t.Hour() < 10 {
   552  		b = append(b, '0')
   553  	}
   554  
   555  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   556  	b = append(b, it.timeSeparator...)
   557  
   558  	if t.Minute() < 10 {
   559  		b = append(b, '0')
   560  	}
   561  
   562  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   563  	b = append(b, it.timeSeparator...)
   564  
   565  	if t.Second() < 10 {
   566  		b = append(b, '0')
   567  	}
   568  
   569  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   570  
   571  	return string(b)
   572  }
   573  
   574  // FmtTimeLong returns the long time representation of 't' for 'it_CH'
   575  func (it *it_CH) FmtTimeLong(t time.Time) string {
   576  
   577  	b := make([]byte, 0, 32)
   578  
   579  	if t.Hour() < 10 {
   580  		b = append(b, '0')
   581  	}
   582  
   583  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   584  	b = append(b, it.timeSeparator...)
   585  
   586  	if t.Minute() < 10 {
   587  		b = append(b, '0')
   588  	}
   589  
   590  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   591  	b = append(b, it.timeSeparator...)
   592  
   593  	if t.Second() < 10 {
   594  		b = append(b, '0')
   595  	}
   596  
   597  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   598  	b = append(b, []byte{0x20}...)
   599  
   600  	tz, _ := t.Zone()
   601  	b = append(b, tz...)
   602  
   603  	return string(b)
   604  }
   605  
   606  // FmtTimeFull returns the full time representation of 't' for 'it_CH'
   607  func (it *it_CH) FmtTimeFull(t time.Time) string {
   608  
   609  	b := make([]byte, 0, 32)
   610  
   611  	if t.Hour() < 10 {
   612  		b = append(b, '0')
   613  	}
   614  
   615  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   616  	b = append(b, it.timeSeparator...)
   617  
   618  	if t.Minute() < 10 {
   619  		b = append(b, '0')
   620  	}
   621  
   622  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   623  	b = append(b, it.timeSeparator...)
   624  
   625  	if t.Second() < 10 {
   626  		b = append(b, '0')
   627  	}
   628  
   629  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   630  	b = append(b, []byte{0x20}...)
   631  
   632  	tz, _ := t.Zone()
   633  
   634  	if btz, ok := it.timezones[tz]; ok {
   635  		b = append(b, btz...)
   636  	} else {
   637  		b = append(b, tz...)
   638  	}
   639  
   640  	return string(b)
   641  }
   642  

View as plain text