...

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

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

     1  package ii_CN
     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 ii_CN 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 'ii_CN' locale
    45  func New() locales.Translator {
    46  	return &ii_CN{
    47  		locale:                 "ii_CN",
    48  		pluralsCardinal:        []locales.PluralRule{6},
    49  		pluralsOrdinal:         nil,
    50  		pluralsRange:           nil,
    51  		decimal:                ".",
    52  		group:                  ",",
    53  		minus:                  "-",
    54  		percent:                "%",
    55  		timeSeparator:          ":",
    56  		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"},
    57  		currencyPositivePrefix: " ",
    58  		currencyNegativePrefix: " ",
    59  		monthsAbbreviated:      []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"},
    60  		monthsNarrow:           []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
    61  		monthsWide:             []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"},
    62  		daysAbbreviated:        []string{"ꑭꆏ", "ꆏꋍ", "ꆏꑍ", "ꆏꌕ", "ꆏꇖ", "ꆏꉬ", "ꆏꃘ"},
    63  		daysNarrow:             []string{"ꆏ", "ꋍ", "ꑍ", "ꌕ", "ꇖ", "ꉬ", "ꃘ"},
    64  		daysWide:               []string{"ꑭꆏꑍ", "ꆏꊂꋍ", "ꆏꊂꑍ", "ꆏꊂꌕ", "ꆏꊂꇖ", "ꆏꊂꉬ", "ꆏꊂꃘ"},
    65  		periodsAbbreviated:     []string{"ꎸꄑ", "ꁯꋒ"},
    66  		periodsWide:            []string{"ꎸꄑ", "ꁯꋒ"},
    67  		erasAbbreviated:        []string{"ꃅꋊꂿ", "ꃅꋊꊂ"},
    68  		erasNarrow:             []string{"", ""},
    69  		erasWide:               []string{"", ""},
    70  		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", "∅∅∅": "∅∅∅"},
    71  	}
    72  }
    73  
    74  // Locale returns the current translators string locale
    75  func (ii *ii_CN) Locale() string {
    76  	return ii.locale
    77  }
    78  
    79  // PluralsCardinal returns the list of cardinal plural rules associated with 'ii_CN'
    80  func (ii *ii_CN) PluralsCardinal() []locales.PluralRule {
    81  	return ii.pluralsCardinal
    82  }
    83  
    84  // PluralsOrdinal returns the list of ordinal plural rules associated with 'ii_CN'
    85  func (ii *ii_CN) PluralsOrdinal() []locales.PluralRule {
    86  	return ii.pluralsOrdinal
    87  }
    88  
    89  // PluralsRange returns the list of range plural rules associated with 'ii_CN'
    90  func (ii *ii_CN) PluralsRange() []locales.PluralRule {
    91  	return ii.pluralsRange
    92  }
    93  
    94  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ii_CN'
    95  func (ii *ii_CN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    96  	return locales.PluralRuleOther
    97  }
    98  
    99  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ii_CN'
   100  func (ii *ii_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   101  	return locales.PluralRuleUnknown
   102  }
   103  
   104  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ii_CN'
   105  func (ii *ii_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   106  	return locales.PluralRuleUnknown
   107  }
   108  
   109  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   110  func (ii *ii_CN) MonthAbbreviated(month time.Month) string {
   111  	return ii.monthsAbbreviated[month]
   112  }
   113  
   114  // MonthsAbbreviated returns the locales abbreviated months
   115  func (ii *ii_CN) MonthsAbbreviated() []string {
   116  	return ii.monthsAbbreviated[1:]
   117  }
   118  
   119  // MonthNarrow returns the locales narrow month given the 'month' provided
   120  func (ii *ii_CN) MonthNarrow(month time.Month) string {
   121  	return ii.monthsNarrow[month]
   122  }
   123  
   124  // MonthsNarrow returns the locales narrow months
   125  func (ii *ii_CN) MonthsNarrow() []string {
   126  	return ii.monthsNarrow[1:]
   127  }
   128  
   129  // MonthWide returns the locales wide month given the 'month' provided
   130  func (ii *ii_CN) MonthWide(month time.Month) string {
   131  	return ii.monthsWide[month]
   132  }
   133  
   134  // MonthsWide returns the locales wide months
   135  func (ii *ii_CN) MonthsWide() []string {
   136  	return ii.monthsWide[1:]
   137  }
   138  
   139  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   140  func (ii *ii_CN) WeekdayAbbreviated(weekday time.Weekday) string {
   141  	return ii.daysAbbreviated[weekday]
   142  }
   143  
   144  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   145  func (ii *ii_CN) WeekdaysAbbreviated() []string {
   146  	return ii.daysAbbreviated
   147  }
   148  
   149  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   150  func (ii *ii_CN) WeekdayNarrow(weekday time.Weekday) string {
   151  	return ii.daysNarrow[weekday]
   152  }
   153  
   154  // WeekdaysNarrow returns the locales narrow weekdays
   155  func (ii *ii_CN) WeekdaysNarrow() []string {
   156  	return ii.daysNarrow
   157  }
   158  
   159  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   160  func (ii *ii_CN) WeekdayShort(weekday time.Weekday) string {
   161  	return ii.daysShort[weekday]
   162  }
   163  
   164  // WeekdaysShort returns the locales short weekdays
   165  func (ii *ii_CN) WeekdaysShort() []string {
   166  	return ii.daysShort
   167  }
   168  
   169  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   170  func (ii *ii_CN) WeekdayWide(weekday time.Weekday) string {
   171  	return ii.daysWide[weekday]
   172  }
   173  
   174  // WeekdaysWide returns the locales wide weekdays
   175  func (ii *ii_CN) WeekdaysWide() []string {
   176  	return ii.daysWide
   177  }
   178  
   179  // Decimal returns the decimal point of number
   180  func (ii *ii_CN) Decimal() string {
   181  	return ii.decimal
   182  }
   183  
   184  // Group returns the group of number
   185  func (ii *ii_CN) Group() string {
   186  	return ii.group
   187  }
   188  
   189  // Group returns the minus sign of number
   190  func (ii *ii_CN) Minus() string {
   191  	return ii.minus
   192  }
   193  
   194  // FmtNumber returns 'num' with digits/precision of 'v' for 'ii_CN' and handles both Whole and Real numbers based on 'v'
   195  func (ii *ii_CN) FmtNumber(num float64, v uint64) string {
   196  
   197  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   198  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   199  	count := 0
   200  	inWhole := v == 0
   201  	b := make([]byte, 0, l)
   202  
   203  	for i := len(s) - 1; i >= 0; i-- {
   204  
   205  		if s[i] == '.' {
   206  			b = append(b, ii.decimal[0])
   207  			inWhole = true
   208  			continue
   209  		}
   210  
   211  		if inWhole {
   212  			if count == 3 {
   213  				b = append(b, ii.group[0])
   214  				count = 1
   215  			} else {
   216  				count++
   217  			}
   218  		}
   219  
   220  		b = append(b, s[i])
   221  	}
   222  
   223  	if num < 0 {
   224  		b = append(b, ii.minus[0])
   225  	}
   226  
   227  	// reverse
   228  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   229  		b[i], b[j] = b[j], b[i]
   230  	}
   231  
   232  	return string(b)
   233  }
   234  
   235  // FmtPercent returns 'num' with digits/precision of 'v' for 'ii_CN' and handles both Whole and Real numbers based on 'v'
   236  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   237  func (ii *ii_CN) FmtPercent(num float64, v uint64) string {
   238  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   239  	l := len(s) + 3
   240  	b := make([]byte, 0, l)
   241  
   242  	for i := len(s) - 1; i >= 0; i-- {
   243  
   244  		if s[i] == '.' {
   245  			b = append(b, ii.decimal[0])
   246  			continue
   247  		}
   248  
   249  		b = append(b, s[i])
   250  	}
   251  
   252  	if num < 0 {
   253  		b = append(b, ii.minus[0])
   254  	}
   255  
   256  	// reverse
   257  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   258  		b[i], b[j] = b[j], b[i]
   259  	}
   260  
   261  	b = append(b, ii.percent...)
   262  
   263  	return string(b)
   264  }
   265  
   266  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ii_CN'
   267  func (ii *ii_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   268  
   269  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   270  	symbol := ii.currencies[currency]
   271  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   272  	count := 0
   273  	inWhole := v == 0
   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, ii.decimal[0])
   280  			inWhole = true
   281  			continue
   282  		}
   283  
   284  		if inWhole {
   285  			if count == 3 {
   286  				b = append(b, ii.group[0])
   287  				count = 1
   288  			} else {
   289  				count++
   290  			}
   291  		}
   292  
   293  		b = append(b, s[i])
   294  	}
   295  
   296  	for j := len(symbol) - 1; j >= 0; j-- {
   297  		b = append(b, symbol[j])
   298  	}
   299  
   300  	for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- {
   301  		b = append(b, ii.currencyPositivePrefix[j])
   302  	}
   303  
   304  	if num < 0 {
   305  		b = append(b, ii.minus[0])
   306  	}
   307  
   308  	// reverse
   309  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   310  		b[i], b[j] = b[j], b[i]
   311  	}
   312  
   313  	if int(v) < 2 {
   314  
   315  		if v == 0 {
   316  			b = append(b, ii.decimal...)
   317  		}
   318  
   319  		for i := 0; i < 2-int(v); i++ {
   320  			b = append(b, '0')
   321  		}
   322  	}
   323  
   324  	return string(b)
   325  }
   326  
   327  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ii_CN'
   328  // in accounting notation.
   329  func (ii *ii_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   330  
   331  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   332  	symbol := ii.currencies[currency]
   333  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   334  	count := 0
   335  	inWhole := v == 0
   336  	b := make([]byte, 0, l)
   337  
   338  	for i := len(s) - 1; i >= 0; i-- {
   339  
   340  		if s[i] == '.' {
   341  			b = append(b, ii.decimal[0])
   342  			inWhole = true
   343  			continue
   344  		}
   345  
   346  		if inWhole {
   347  			if count == 3 {
   348  				b = append(b, ii.group[0])
   349  				count = 1
   350  			} else {
   351  				count++
   352  			}
   353  		}
   354  
   355  		b = append(b, s[i])
   356  	}
   357  
   358  	if num < 0 {
   359  
   360  		for j := len(symbol) - 1; j >= 0; j-- {
   361  			b = append(b, symbol[j])
   362  		}
   363  
   364  		for j := len(ii.currencyNegativePrefix) - 1; j >= 0; j-- {
   365  			b = append(b, ii.currencyNegativePrefix[j])
   366  		}
   367  
   368  		b = append(b, ii.minus[0])
   369  
   370  	} else {
   371  
   372  		for j := len(symbol) - 1; j >= 0; j-- {
   373  			b = append(b, symbol[j])
   374  		}
   375  
   376  		for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- {
   377  			b = append(b, ii.currencyPositivePrefix[j])
   378  		}
   379  
   380  	}
   381  
   382  	// reverse
   383  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   384  		b[i], b[j] = b[j], b[i]
   385  	}
   386  
   387  	if int(v) < 2 {
   388  
   389  		if v == 0 {
   390  			b = append(b, ii.decimal...)
   391  		}
   392  
   393  		for i := 0; i < 2-int(v); i++ {
   394  			b = append(b, '0')
   395  		}
   396  	}
   397  
   398  	return string(b)
   399  }
   400  
   401  // FmtDateShort returns the short date representation of 't' for 'ii_CN'
   402  func (ii *ii_CN) FmtDateShort(t time.Time) string {
   403  
   404  	b := make([]byte, 0, 32)
   405  
   406  	if t.Year() > 0 {
   407  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   408  	} else {
   409  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   410  	}
   411  
   412  	b = append(b, []byte{0x2d}...)
   413  
   414  	if t.Month() < 10 {
   415  		b = append(b, '0')
   416  	}
   417  
   418  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   419  
   420  	b = append(b, []byte{0x2d}...)
   421  
   422  	if t.Day() < 10 {
   423  		b = append(b, '0')
   424  	}
   425  
   426  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   427  
   428  	return string(b)
   429  }
   430  
   431  // FmtDateMedium returns the medium date representation of 't' for 'ii_CN'
   432  func (ii *ii_CN) FmtDateMedium(t time.Time) string {
   433  
   434  	b := make([]byte, 0, 32)
   435  
   436  	if t.Year() > 0 {
   437  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   438  	} else {
   439  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   440  	}
   441  
   442  	b = append(b, []byte{0x20}...)
   443  	b = append(b, ii.monthsAbbreviated[t.Month()]...)
   444  	b = append(b, []byte{0x20}...)
   445  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   446  
   447  	return string(b)
   448  }
   449  
   450  // FmtDateLong returns the long date representation of 't' for 'ii_CN'
   451  func (ii *ii_CN) FmtDateLong(t time.Time) string {
   452  
   453  	b := make([]byte, 0, 32)
   454  
   455  	if t.Year() > 0 {
   456  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   457  	} else {
   458  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   459  	}
   460  
   461  	b = append(b, []byte{0x20}...)
   462  	b = append(b, ii.monthsWide[t.Month()]...)
   463  	b = append(b, []byte{0x20}...)
   464  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   465  
   466  	return string(b)
   467  }
   468  
   469  // FmtDateFull returns the full date representation of 't' for 'ii_CN'
   470  func (ii *ii_CN) FmtDateFull(t time.Time) string {
   471  
   472  	b := make([]byte, 0, 32)
   473  
   474  	if t.Year() > 0 {
   475  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   476  	} else {
   477  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   478  	}
   479  
   480  	b = append(b, []byte{0x20}...)
   481  	b = append(b, ii.monthsWide[t.Month()]...)
   482  	b = append(b, []byte{0x20}...)
   483  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   484  	b = append(b, []byte{0x2c, 0x20}...)
   485  	b = append(b, ii.daysWide[t.Weekday()]...)
   486  
   487  	return string(b)
   488  }
   489  
   490  // FmtTimeShort returns the short time representation of 't' for 'ii_CN'
   491  func (ii *ii_CN) FmtTimeShort(t time.Time) string {
   492  
   493  	b := make([]byte, 0, 32)
   494  
   495  	h := t.Hour()
   496  
   497  	if h > 12 {
   498  		h -= 12
   499  	}
   500  
   501  	b = strconv.AppendInt(b, int64(h), 10)
   502  	b = append(b, ii.timeSeparator...)
   503  
   504  	if t.Minute() < 10 {
   505  		b = append(b, '0')
   506  	}
   507  
   508  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   509  	b = append(b, []byte{0x20}...)
   510  
   511  	if t.Hour() < 12 {
   512  		b = append(b, ii.periodsAbbreviated[0]...)
   513  	} else {
   514  		b = append(b, ii.periodsAbbreviated[1]...)
   515  	}
   516  
   517  	return string(b)
   518  }
   519  
   520  // FmtTimeMedium returns the medium time representation of 't' for 'ii_CN'
   521  func (ii *ii_CN) FmtTimeMedium(t time.Time) string {
   522  
   523  	b := make([]byte, 0, 32)
   524  
   525  	h := t.Hour()
   526  
   527  	if h > 12 {
   528  		h -= 12
   529  	}
   530  
   531  	b = strconv.AppendInt(b, int64(h), 10)
   532  	b = append(b, ii.timeSeparator...)
   533  
   534  	if t.Minute() < 10 {
   535  		b = append(b, '0')
   536  	}
   537  
   538  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   539  	b = append(b, ii.timeSeparator...)
   540  
   541  	if t.Second() < 10 {
   542  		b = append(b, '0')
   543  	}
   544  
   545  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   546  	b = append(b, []byte{0x20}...)
   547  
   548  	if t.Hour() < 12 {
   549  		b = append(b, ii.periodsAbbreviated[0]...)
   550  	} else {
   551  		b = append(b, ii.periodsAbbreviated[1]...)
   552  	}
   553  
   554  	return string(b)
   555  }
   556  
   557  // FmtTimeLong returns the long time representation of 't' for 'ii_CN'
   558  func (ii *ii_CN) FmtTimeLong(t time.Time) string {
   559  
   560  	b := make([]byte, 0, 32)
   561  
   562  	h := t.Hour()
   563  
   564  	if h > 12 {
   565  		h -= 12
   566  	}
   567  
   568  	b = strconv.AppendInt(b, int64(h), 10)
   569  	b = append(b, ii.timeSeparator...)
   570  
   571  	if t.Minute() < 10 {
   572  		b = append(b, '0')
   573  	}
   574  
   575  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   576  	b = append(b, ii.timeSeparator...)
   577  
   578  	if t.Second() < 10 {
   579  		b = append(b, '0')
   580  	}
   581  
   582  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   583  	b = append(b, []byte{0x20}...)
   584  
   585  	if t.Hour() < 12 {
   586  		b = append(b, ii.periodsAbbreviated[0]...)
   587  	} else {
   588  		b = append(b, ii.periodsAbbreviated[1]...)
   589  	}
   590  
   591  	b = append(b, []byte{0x20}...)
   592  
   593  	tz, _ := t.Zone()
   594  	b = append(b, tz...)
   595  
   596  	return string(b)
   597  }
   598  
   599  // FmtTimeFull returns the full time representation of 't' for 'ii_CN'
   600  func (ii *ii_CN) FmtTimeFull(t time.Time) string {
   601  
   602  	b := make([]byte, 0, 32)
   603  
   604  	h := t.Hour()
   605  
   606  	if h > 12 {
   607  		h -= 12
   608  	}
   609  
   610  	b = strconv.AppendInt(b, int64(h), 10)
   611  	b = append(b, ii.timeSeparator...)
   612  
   613  	if t.Minute() < 10 {
   614  		b = append(b, '0')
   615  	}
   616  
   617  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   618  	b = append(b, ii.timeSeparator...)
   619  
   620  	if t.Second() < 10 {
   621  		b = append(b, '0')
   622  	}
   623  
   624  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   625  	b = append(b, []byte{0x20}...)
   626  
   627  	if t.Hour() < 12 {
   628  		b = append(b, ii.periodsAbbreviated[0]...)
   629  	} else {
   630  		b = append(b, ii.periodsAbbreviated[1]...)
   631  	}
   632  
   633  	b = append(b, []byte{0x20}...)
   634  
   635  	tz, _ := t.Zone()
   636  
   637  	if btz, ok := ii.timezones[tz]; ok {
   638  		b = append(b, btz...)
   639  	} else {
   640  		b = append(b, tz...)
   641  	}
   642  
   643  	return string(b)
   644  }
   645  

View as plain text