...

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

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

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

View as plain text