...

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

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

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

View as plain text