...

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

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

     1  package zh_Hans_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 zh_Hans_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  	monthsAbbreviated  []string
    26  	monthsNarrow       []string
    27  	monthsWide         []string
    28  	daysAbbreviated    []string
    29  	daysNarrow         []string
    30  	daysShort          []string
    31  	daysWide           []string
    32  	periodsAbbreviated []string
    33  	periodsNarrow      []string
    34  	periodsShort       []string
    35  	periodsWide        []string
    36  	erasAbbreviated    []string
    37  	erasNarrow         []string
    38  	erasWide           []string
    39  	timezones          map[string]string
    40  }
    41  
    42  // New returns a new instance of translator for the 'zh_Hans_CN' locale
    43  func New() locales.Translator {
    44  	return &zh_Hans_CN{
    45  		locale:             "zh_Hans_CN",
    46  		pluralsCardinal:    []locales.PluralRule{6},
    47  		pluralsOrdinal:     []locales.PluralRule{6},
    48  		pluralsRange:       []locales.PluralRule{6},
    49  		decimal:            ".",
    50  		group:              ",",
    51  		minus:              "-",
    52  		percent:            "%",
    53  		perMille:           "‰",
    54  		timeSeparator:      ":",
    55  		inifinity:          "∞",
    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  		monthsAbbreviated:  []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
    58  		monthsNarrow:       []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
    59  		monthsWide:         []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"},
    60  		daysAbbreviated:    []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"},
    61  		daysNarrow:         []string{"日", "一", "二", "三", "四", "五", "六"},
    62  		daysShort:          []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"},
    63  		daysWide:           []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"},
    64  		periodsAbbreviated: []string{"上午", "下午"},
    65  		periodsNarrow:      []string{"上午", "下午"},
    66  		periodsWide:        []string{"上午", "下午"},
    67  		erasAbbreviated:    []string{"公元前", "公元"},
    68  		erasNarrow:         []string{"公元前", "公元"},
    69  		erasWide:           []string{"公元前", "公元"},
    70  		timezones:          map[string]string{"ACDT": "澳大利亚中部夏令时间", "ACST": "澳大利亚中部标准时间", "ACWDT": "澳大利亚中西部夏令时间", "ACWST": "澳大利亚中西部标准时间", "ADT": "大西洋夏令时间", "AEDT": "澳大利亚东部夏令时间", "AEST": "澳大利亚东部标准时间", "AKDT": "阿拉斯加夏令时间", "AKST": "阿拉斯加标准时间", "ARST": "阿根廷夏令时间", "ART": "阿根廷标准时间", "AST": "大西洋标准时间", "AWDT": "澳大利亚西部夏令时间", "AWST": "澳大利亚西部标准时间", "BOT": "玻利维亚标准时间", "BT": "不丹时间", "CAT": "中部非洲时间", "CDT": "北美中部夏令时间", "CHADT": "查坦夏令时间", "CHAST": "查坦标准时间", "CLST": "智利夏令时间", "CLT": "智利标准时间", "COST": "哥伦比亚夏令时间", "COT": "哥伦比亚标准时间", "CST": "北美中部标准时间", "ChST": "查莫罗时间", "EAT": "东部非洲时间", "ECT": "厄瓜多尔标准时间", "EDT": "北美东部夏令时间", "EST": "北美东部标准时间", "GFT": "法属圭亚那标准时间", "GMT": "格林尼治标准时间", "GST": "海湾标准时间", "GYT": "圭亚那时间", "HADT": "夏威夷-阿留申夏令时间", "HAST": "夏威夷-阿留申标准时间", "HAT": "纽芬兰夏令时间", "HECU": "古巴夏令时间", "HEEG": "格陵兰岛东部夏令时间", "HENOMX": "墨西哥西北部夏令时间", "HEOG": "格陵兰岛西部夏令时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "HEPMX": "墨西哥太平洋夏令时间", "HKST": "香港夏令时间", "HKT": "香港标准时间", "HNCU": "古巴标准时间", "HNEG": "格陵兰岛东部标准时间", "HNNOMX": "墨西哥西北部标准时间", "HNOG": "格陵兰岛西部标准时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "HNPMX": "墨西哥太平洋标准时间", "HNT": "纽芬兰标准时间", "IST": "印度时间", "JDT": "日本夏令时间", "JST": "日本标准时间", "LHDT": "豪勋爵岛夏令时间", "LHST": "豪勋爵岛标准时间", "MDT": "北美山区夏令时间", "MESZ": "中欧夏令时间", "MEZ": "中欧标准时间", "MST": "北美山区标准时间", "MYT": "马来西亚时间", "NZDT": "新西兰夏令时间", "NZST": "新西兰标准时间", "OESZ": "东欧夏令时间", "OEZ": "东欧标准时间", "PDT": "北美太平洋夏令时间", "PST": "北美太平洋标准时间", "SAST": "南非标准时间", "SGT": "新加坡标准时间", "SRT": "苏里南时间", "TMST": "土库曼斯坦夏令时间", "TMT": "土库曼斯坦标准时间", "UYST": "乌拉圭夏令时间", "UYT": "乌拉圭标准时间", "VET": "委内瑞拉时间", "WARST": "阿根廷西部夏令时间", "WART": "阿根廷西部标准时间", "WAST": "西部非洲夏令时间", "WAT": "西部非洲标准时间", "WESZ": "西欧夏令时间", "WEZ": "西欧标准时间", "WIB": "印度尼西亚西部时间", "WIT": "印度尼西亚东部时间", "WITA": "印度尼西亚中部时间", "∅∅∅": "亚速尔群岛夏令时间"},
    71  	}
    72  }
    73  
    74  // Locale returns the current translators string locale
    75  func (zh *zh_Hans_CN) Locale() string {
    76  	return zh.locale
    77  }
    78  
    79  // PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans_CN'
    80  func (zh *zh_Hans_CN) PluralsCardinal() []locales.PluralRule {
    81  	return zh.pluralsCardinal
    82  }
    83  
    84  // PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans_CN'
    85  func (zh *zh_Hans_CN) PluralsOrdinal() []locales.PluralRule {
    86  	return zh.pluralsOrdinal
    87  }
    88  
    89  // PluralsRange returns the list of range plural rules associated with 'zh_Hans_CN'
    90  func (zh *zh_Hans_CN) PluralsRange() []locales.PluralRule {
    91  	return zh.pluralsRange
    92  }
    93  
    94  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_CN'
    95  func (zh *zh_Hans_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 'zh_Hans_CN'
   100  func (zh *zh_Hans_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   101  	return locales.PluralRuleOther
   102  }
   103  
   104  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans_CN'
   105  func (zh *zh_Hans_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   106  	return locales.PluralRuleOther
   107  }
   108  
   109  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   110  func (zh *zh_Hans_CN) MonthAbbreviated(month time.Month) string {
   111  	return zh.monthsAbbreviated[month]
   112  }
   113  
   114  // MonthsAbbreviated returns the locales abbreviated months
   115  func (zh *zh_Hans_CN) MonthsAbbreviated() []string {
   116  	return zh.monthsAbbreviated[1:]
   117  }
   118  
   119  // MonthNarrow returns the locales narrow month given the 'month' provided
   120  func (zh *zh_Hans_CN) MonthNarrow(month time.Month) string {
   121  	return zh.monthsNarrow[month]
   122  }
   123  
   124  // MonthsNarrow returns the locales narrow months
   125  func (zh *zh_Hans_CN) MonthsNarrow() []string {
   126  	return zh.monthsNarrow[1:]
   127  }
   128  
   129  // MonthWide returns the locales wide month given the 'month' provided
   130  func (zh *zh_Hans_CN) MonthWide(month time.Month) string {
   131  	return zh.monthsWide[month]
   132  }
   133  
   134  // MonthsWide returns the locales wide months
   135  func (zh *zh_Hans_CN) MonthsWide() []string {
   136  	return zh.monthsWide[1:]
   137  }
   138  
   139  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   140  func (zh *zh_Hans_CN) WeekdayAbbreviated(weekday time.Weekday) string {
   141  	return zh.daysAbbreviated[weekday]
   142  }
   143  
   144  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   145  func (zh *zh_Hans_CN) WeekdaysAbbreviated() []string {
   146  	return zh.daysAbbreviated
   147  }
   148  
   149  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   150  func (zh *zh_Hans_CN) WeekdayNarrow(weekday time.Weekday) string {
   151  	return zh.daysNarrow[weekday]
   152  }
   153  
   154  // WeekdaysNarrow returns the locales narrow weekdays
   155  func (zh *zh_Hans_CN) WeekdaysNarrow() []string {
   156  	return zh.daysNarrow
   157  }
   158  
   159  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   160  func (zh *zh_Hans_CN) WeekdayShort(weekday time.Weekday) string {
   161  	return zh.daysShort[weekday]
   162  }
   163  
   164  // WeekdaysShort returns the locales short weekdays
   165  func (zh *zh_Hans_CN) WeekdaysShort() []string {
   166  	return zh.daysShort
   167  }
   168  
   169  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   170  func (zh *zh_Hans_CN) WeekdayWide(weekday time.Weekday) string {
   171  	return zh.daysWide[weekday]
   172  }
   173  
   174  // WeekdaysWide returns the locales wide weekdays
   175  func (zh *zh_Hans_CN) WeekdaysWide() []string {
   176  	return zh.daysWide
   177  }
   178  
   179  // Decimal returns the decimal point of number
   180  func (zh *zh_Hans_CN) Decimal() string {
   181  	return zh.decimal
   182  }
   183  
   184  // Group returns the group of number
   185  func (zh *zh_Hans_CN) Group() string {
   186  	return zh.group
   187  }
   188  
   189  // Group returns the minus sign of number
   190  func (zh *zh_Hans_CN) Minus() string {
   191  	return zh.minus
   192  }
   193  
   194  // FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans_CN' and handles both Whole and Real numbers based on 'v'
   195  func (zh *zh_Hans_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, zh.decimal[0])
   207  			inWhole = true
   208  			continue
   209  		}
   210  
   211  		if inWhole {
   212  			if count == 3 {
   213  				b = append(b, zh.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, zh.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 'zh_Hans_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 (zh *zh_Hans_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, zh.decimal[0])
   246  			continue
   247  		}
   248  
   249  		b = append(b, s[i])
   250  	}
   251  
   252  	if num < 0 {
   253  		b = append(b, zh.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, zh.percent...)
   262  
   263  	return string(b)
   264  }
   265  
   266  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_CN'
   267  func (zh *zh_Hans_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   268  
   269  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   270  	symbol := zh.currencies[currency]
   271  	l := len(s) + len(symbol) + 2 + 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, zh.decimal[0])
   280  			inWhole = true
   281  			continue
   282  		}
   283  
   284  		if inWhole {
   285  			if count == 3 {
   286  				b = append(b, zh.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  	if num < 0 {
   301  		b = append(b, zh.minus[0])
   302  	}
   303  
   304  	// reverse
   305  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   306  		b[i], b[j] = b[j], b[i]
   307  	}
   308  
   309  	if int(v) < 2 {
   310  
   311  		if v == 0 {
   312  			b = append(b, zh.decimal...)
   313  		}
   314  
   315  		for i := 0; i < 2-int(v); i++ {
   316  			b = append(b, '0')
   317  		}
   318  	}
   319  
   320  	return string(b)
   321  }
   322  
   323  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_CN'
   324  // in accounting notation.
   325  func (zh *zh_Hans_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   326  
   327  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   328  	symbol := zh.currencies[currency]
   329  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   330  	count := 0
   331  	inWhole := v == 0
   332  	b := make([]byte, 0, l)
   333  
   334  	for i := len(s) - 1; i >= 0; i-- {
   335  
   336  		if s[i] == '.' {
   337  			b = append(b, zh.decimal[0])
   338  			inWhole = true
   339  			continue
   340  		}
   341  
   342  		if inWhole {
   343  			if count == 3 {
   344  				b = append(b, zh.group[0])
   345  				count = 1
   346  			} else {
   347  				count++
   348  			}
   349  		}
   350  
   351  		b = append(b, s[i])
   352  	}
   353  
   354  	if num < 0 {
   355  
   356  		for j := len(symbol) - 1; j >= 0; j-- {
   357  			b = append(b, symbol[j])
   358  		}
   359  
   360  		b = append(b, zh.minus[0])
   361  
   362  	} else {
   363  
   364  		for j := len(symbol) - 1; j >= 0; j-- {
   365  			b = append(b, symbol[j])
   366  		}
   367  
   368  	}
   369  
   370  	// reverse
   371  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   372  		b[i], b[j] = b[j], b[i]
   373  	}
   374  
   375  	if int(v) < 2 {
   376  
   377  		if v == 0 {
   378  			b = append(b, zh.decimal...)
   379  		}
   380  
   381  		for i := 0; i < 2-int(v); i++ {
   382  			b = append(b, '0')
   383  		}
   384  	}
   385  
   386  	return string(b)
   387  }
   388  
   389  // FmtDateShort returns the short date representation of 't' for 'zh_Hans_CN'
   390  func (zh *zh_Hans_CN) FmtDateShort(t time.Time) string {
   391  
   392  	b := make([]byte, 0, 32)
   393  
   394  	if t.Year() > 0 {
   395  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   396  	} else {
   397  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   398  	}
   399  
   400  	b = append(b, []byte{0x2f}...)
   401  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   402  	b = append(b, []byte{0x2f}...)
   403  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   404  
   405  	return string(b)
   406  }
   407  
   408  // FmtDateMedium returns the medium date representation of 't' for 'zh_Hans_CN'
   409  func (zh *zh_Hans_CN) FmtDateMedium(t time.Time) string {
   410  
   411  	b := make([]byte, 0, 32)
   412  
   413  	if t.Year() > 0 {
   414  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   415  	} else {
   416  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   417  	}
   418  
   419  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   420  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   421  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   422  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   423  	b = append(b, []byte{0xe6, 0x97, 0xa5}...)
   424  
   425  	return string(b)
   426  }
   427  
   428  // FmtDateLong returns the long date representation of 't' for 'zh_Hans_CN'
   429  func (zh *zh_Hans_CN) FmtDateLong(t time.Time) string {
   430  
   431  	b := make([]byte, 0, 32)
   432  
   433  	if t.Year() > 0 {
   434  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   435  	} else {
   436  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   437  	}
   438  
   439  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   440  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   441  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   442  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   443  	b = append(b, []byte{0xe6, 0x97, 0xa5}...)
   444  
   445  	return string(b)
   446  }
   447  
   448  // FmtDateFull returns the full date representation of 't' for 'zh_Hans_CN'
   449  func (zh *zh_Hans_CN) FmtDateFull(t time.Time) string {
   450  
   451  	b := make([]byte, 0, 32)
   452  
   453  	if t.Year() > 0 {
   454  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   455  	} else {
   456  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   457  	}
   458  
   459  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   460  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   461  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   462  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   463  	b = append(b, []byte{0xe6, 0x97, 0xa5}...)
   464  	b = append(b, zh.daysWide[t.Weekday()]...)
   465  
   466  	return string(b)
   467  }
   468  
   469  // FmtTimeShort returns the short time representation of 't' for 'zh_Hans_CN'
   470  func (zh *zh_Hans_CN) FmtTimeShort(t time.Time) string {
   471  
   472  	b := make([]byte, 0, 32)
   473  
   474  	if t.Hour() < 12 {
   475  		b = append(b, zh.periodsAbbreviated[0]...)
   476  	} else {
   477  		b = append(b, zh.periodsAbbreviated[1]...)
   478  	}
   479  
   480  	h := t.Hour()
   481  
   482  	if h > 12 {
   483  		h -= 12
   484  	}
   485  
   486  	b = strconv.AppendInt(b, int64(h), 10)
   487  	b = append(b, zh.timeSeparator...)
   488  
   489  	if t.Minute() < 10 {
   490  		b = append(b, '0')
   491  	}
   492  
   493  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   494  
   495  	return string(b)
   496  }
   497  
   498  // FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_CN'
   499  func (zh *zh_Hans_CN) FmtTimeMedium(t time.Time) string {
   500  
   501  	b := make([]byte, 0, 32)
   502  
   503  	if t.Hour() < 12 {
   504  		b = append(b, zh.periodsAbbreviated[0]...)
   505  	} else {
   506  		b = append(b, zh.periodsAbbreviated[1]...)
   507  	}
   508  
   509  	h := t.Hour()
   510  
   511  	if h > 12 {
   512  		h -= 12
   513  	}
   514  
   515  	b = strconv.AppendInt(b, int64(h), 10)
   516  	b = append(b, zh.timeSeparator...)
   517  
   518  	if t.Minute() < 10 {
   519  		b = append(b, '0')
   520  	}
   521  
   522  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   523  	b = append(b, zh.timeSeparator...)
   524  
   525  	if t.Second() < 10 {
   526  		b = append(b, '0')
   527  	}
   528  
   529  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   530  
   531  	return string(b)
   532  }
   533  
   534  // FmtTimeLong returns the long time representation of 't' for 'zh_Hans_CN'
   535  func (zh *zh_Hans_CN) FmtTimeLong(t time.Time) string {
   536  
   537  	b := make([]byte, 0, 32)
   538  
   539  	tz, _ := t.Zone()
   540  	b = append(b, tz...)
   541  
   542  	b = append(b, []byte{0x20}...)
   543  
   544  	if t.Hour() < 12 {
   545  		b = append(b, zh.periodsAbbreviated[0]...)
   546  	} else {
   547  		b = append(b, zh.periodsAbbreviated[1]...)
   548  	}
   549  
   550  	h := t.Hour()
   551  
   552  	if h > 12 {
   553  		h -= 12
   554  	}
   555  
   556  	b = strconv.AppendInt(b, int64(h), 10)
   557  	b = append(b, zh.timeSeparator...)
   558  
   559  	if t.Minute() < 10 {
   560  		b = append(b, '0')
   561  	}
   562  
   563  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   564  	b = append(b, zh.timeSeparator...)
   565  
   566  	if t.Second() < 10 {
   567  		b = append(b, '0')
   568  	}
   569  
   570  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   571  
   572  	return string(b)
   573  }
   574  
   575  // FmtTimeFull returns the full time representation of 't' for 'zh_Hans_CN'
   576  func (zh *zh_Hans_CN) FmtTimeFull(t time.Time) string {
   577  
   578  	b := make([]byte, 0, 32)
   579  
   580  	tz, _ := t.Zone()
   581  
   582  	if btz, ok := zh.timezones[tz]; ok {
   583  		b = append(b, btz...)
   584  	} else {
   585  		b = append(b, tz...)
   586  	}
   587  
   588  	b = append(b, []byte{0x20}...)
   589  
   590  	if t.Hour() < 12 {
   591  		b = append(b, zh.periodsAbbreviated[0]...)
   592  	} else {
   593  		b = append(b, zh.periodsAbbreviated[1]...)
   594  	}
   595  
   596  	h := t.Hour()
   597  
   598  	if h > 12 {
   599  		h -= 12
   600  	}
   601  
   602  	b = strconv.AppendInt(b, int64(h), 10)
   603  	b = append(b, zh.timeSeparator...)
   604  
   605  	if t.Minute() < 10 {
   606  		b = append(b, '0')
   607  	}
   608  
   609  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   610  	b = append(b, zh.timeSeparator...)
   611  
   612  	if t.Second() < 10 {
   613  		b = append(b, '0')
   614  	}
   615  
   616  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   617  
   618  	return string(b)
   619  }
   620  

View as plain text