...

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

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

     1  package zh_Hant
     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_Hant 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  	currencyNegativePrefix string
    26  	currencyNegativeSuffix 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 'zh_Hant' locale
    45  func New() locales.Translator {
    46  	return &zh_Hant{
    47  		locale:                 "zh_Hant",
    48  		pluralsCardinal:        []locales.PluralRule{6},
    49  		pluralsOrdinal:         []locales.PluralRule{6},
    50  		pluralsRange:           []locales.PluralRule{6},
    51  		decimal:                ".",
    52  		group:                  ",",
    53  		minus:                  "-",
    54  		percent:                "%",
    55  		perMille:               "‰",
    56  		timeSeparator:          ":",
    57  		inifinity:              "∞",
    58  		currencies:             []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "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", "Db", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
    59  		currencyNegativePrefix: "(",
    60  		currencyNegativeSuffix: ")",
    61  		monthsAbbreviated:      []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
    62  		monthsNarrow:           []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
    63  		monthsWide:             []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
    64  		daysAbbreviated:        []string{"週日", "週一", "週二", "週三", "週四", "週五", "週六"},
    65  		daysNarrow:             []string{"日", "一", "二", "三", "四", "五", "六"},
    66  		daysShort:              []string{"日", "一", "二", "三", "四", "五", "六"},
    67  		daysWide:               []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"},
    68  		periodsAbbreviated:     []string{"上午", "下午"},
    69  		periodsNarrow:          []string{"上午", "下午"},
    70  		periodsWide:            []string{"上午", "下午"},
    71  		erasAbbreviated:        []string{"西元前", "西元"},
    72  		erasNarrow:             []string{"西元前", "西元"},
    73  		erasWide:               []string{"西元前", "西元"},
    74  		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": "印尼中部時間", "∅∅∅": "巴西利亞夏令時間"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (zh *zh_Hant) Locale() string {
    80  	return zh.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hant'
    84  func (zh *zh_Hant) PluralsCardinal() []locales.PluralRule {
    85  	return zh.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hant'
    89  func (zh *zh_Hant) PluralsOrdinal() []locales.PluralRule {
    90  	return zh.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'zh_Hant'
    94  func (zh *zh_Hant) PluralsRange() []locales.PluralRule {
    95  	return zh.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant'
    99  func (zh *zh_Hant) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  	return locales.PluralRuleOther
   101  }
   102  
   103  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant'
   104  func (zh *zh_Hant) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   105  	return locales.PluralRuleOther
   106  }
   107  
   108  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hant'
   109  func (zh *zh_Hant) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   110  	return locales.PluralRuleOther
   111  }
   112  
   113  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   114  func (zh *zh_Hant) MonthAbbreviated(month time.Month) string {
   115  	return zh.monthsAbbreviated[month]
   116  }
   117  
   118  // MonthsAbbreviated returns the locales abbreviated months
   119  func (zh *zh_Hant) MonthsAbbreviated() []string {
   120  	return zh.monthsAbbreviated[1:]
   121  }
   122  
   123  // MonthNarrow returns the locales narrow month given the 'month' provided
   124  func (zh *zh_Hant) MonthNarrow(month time.Month) string {
   125  	return zh.monthsNarrow[month]
   126  }
   127  
   128  // MonthsNarrow returns the locales narrow months
   129  func (zh *zh_Hant) MonthsNarrow() []string {
   130  	return zh.monthsNarrow[1:]
   131  }
   132  
   133  // MonthWide returns the locales wide month given the 'month' provided
   134  func (zh *zh_Hant) MonthWide(month time.Month) string {
   135  	return zh.monthsWide[month]
   136  }
   137  
   138  // MonthsWide returns the locales wide months
   139  func (zh *zh_Hant) MonthsWide() []string {
   140  	return zh.monthsWide[1:]
   141  }
   142  
   143  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   144  func (zh *zh_Hant) WeekdayAbbreviated(weekday time.Weekday) string {
   145  	return zh.daysAbbreviated[weekday]
   146  }
   147  
   148  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   149  func (zh *zh_Hant) WeekdaysAbbreviated() []string {
   150  	return zh.daysAbbreviated
   151  }
   152  
   153  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   154  func (zh *zh_Hant) WeekdayNarrow(weekday time.Weekday) string {
   155  	return zh.daysNarrow[weekday]
   156  }
   157  
   158  // WeekdaysNarrow returns the locales narrow weekdays
   159  func (zh *zh_Hant) WeekdaysNarrow() []string {
   160  	return zh.daysNarrow
   161  }
   162  
   163  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   164  func (zh *zh_Hant) WeekdayShort(weekday time.Weekday) string {
   165  	return zh.daysShort[weekday]
   166  }
   167  
   168  // WeekdaysShort returns the locales short weekdays
   169  func (zh *zh_Hant) WeekdaysShort() []string {
   170  	return zh.daysShort
   171  }
   172  
   173  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   174  func (zh *zh_Hant) WeekdayWide(weekday time.Weekday) string {
   175  	return zh.daysWide[weekday]
   176  }
   177  
   178  // WeekdaysWide returns the locales wide weekdays
   179  func (zh *zh_Hant) WeekdaysWide() []string {
   180  	return zh.daysWide
   181  }
   182  
   183  // Decimal returns the decimal point of number
   184  func (zh *zh_Hant) Decimal() string {
   185  	return zh.decimal
   186  }
   187  
   188  // Group returns the group of number
   189  func (zh *zh_Hant) Group() string {
   190  	return zh.group
   191  }
   192  
   193  // Group returns the minus sign of number
   194  func (zh *zh_Hant) Minus() string {
   195  	return zh.minus
   196  }
   197  
   198  // FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hant' and handles both Whole and Real numbers based on 'v'
   199  func (zh *zh_Hant) FmtNumber(num float64, v uint64) string {
   200  
   201  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   202  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   203  	count := 0
   204  	inWhole := v == 0
   205  	b := make([]byte, 0, l)
   206  
   207  	for i := len(s) - 1; i >= 0; i-- {
   208  
   209  		if s[i] == '.' {
   210  			b = append(b, zh.decimal[0])
   211  			inWhole = true
   212  			continue
   213  		}
   214  
   215  		if inWhole {
   216  			if count == 3 {
   217  				b = append(b, zh.group[0])
   218  				count = 1
   219  			} else {
   220  				count++
   221  			}
   222  		}
   223  
   224  		b = append(b, s[i])
   225  	}
   226  
   227  	if num < 0 {
   228  		b = append(b, zh.minus[0])
   229  	}
   230  
   231  	// reverse
   232  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   233  		b[i], b[j] = b[j], b[i]
   234  	}
   235  
   236  	return string(b)
   237  }
   238  
   239  // FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hant' and handles both Whole and Real numbers based on 'v'
   240  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   241  func (zh *zh_Hant) FmtPercent(num float64, v uint64) string {
   242  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   243  	l := len(s) + 3
   244  	b := make([]byte, 0, l)
   245  
   246  	for i := len(s) - 1; i >= 0; i-- {
   247  
   248  		if s[i] == '.' {
   249  			b = append(b, zh.decimal[0])
   250  			continue
   251  		}
   252  
   253  		b = append(b, s[i])
   254  	}
   255  
   256  	if num < 0 {
   257  		b = append(b, zh.minus[0])
   258  	}
   259  
   260  	// reverse
   261  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   262  		b[i], b[j] = b[j], b[i]
   263  	}
   264  
   265  	b = append(b, zh.percent...)
   266  
   267  	return string(b)
   268  }
   269  
   270  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant'
   271  func (zh *zh_Hant) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   272  
   273  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   274  	symbol := zh.currencies[currency]
   275  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   276  	count := 0
   277  	inWhole := v == 0
   278  	b := make([]byte, 0, l)
   279  
   280  	for i := len(s) - 1; i >= 0; i-- {
   281  
   282  		if s[i] == '.' {
   283  			b = append(b, zh.decimal[0])
   284  			inWhole = true
   285  			continue
   286  		}
   287  
   288  		if inWhole {
   289  			if count == 3 {
   290  				b = append(b, zh.group[0])
   291  				count = 1
   292  			} else {
   293  				count++
   294  			}
   295  		}
   296  
   297  		b = append(b, s[i])
   298  	}
   299  
   300  	for j := len(symbol) - 1; j >= 0; j-- {
   301  		b = append(b, symbol[j])
   302  	}
   303  
   304  	if num < 0 {
   305  		b = append(b, zh.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, zh.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 'zh_Hant'
   328  // in accounting notation.
   329  func (zh *zh_Hant) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   330  
   331  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   332  	symbol := zh.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, zh.decimal[0])
   342  			inWhole = true
   343  			continue
   344  		}
   345  
   346  		if inWhole {
   347  			if count == 3 {
   348  				b = append(b, zh.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  		b = append(b, zh.currencyNegativePrefix[0])
   365  
   366  	} else {
   367  
   368  		for j := len(symbol) - 1; j >= 0; j-- {
   369  			b = append(b, symbol[j])
   370  		}
   371  
   372  	}
   373  
   374  	// reverse
   375  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   376  		b[i], b[j] = b[j], b[i]
   377  	}
   378  
   379  	if int(v) < 2 {
   380  
   381  		if v == 0 {
   382  			b = append(b, zh.decimal...)
   383  		}
   384  
   385  		for i := 0; i < 2-int(v); i++ {
   386  			b = append(b, '0')
   387  		}
   388  	}
   389  
   390  	if num < 0 {
   391  		b = append(b, zh.currencyNegativeSuffix...)
   392  	}
   393  
   394  	return string(b)
   395  }
   396  
   397  // FmtDateShort returns the short date representation of 't' for 'zh_Hant'
   398  func (zh *zh_Hant) FmtDateShort(t time.Time) string {
   399  
   400  	b := make([]byte, 0, 32)
   401  
   402  	if t.Year() > 0 {
   403  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   404  	} else {
   405  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   406  	}
   407  
   408  	b = append(b, []byte{0x2f}...)
   409  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   410  	b = append(b, []byte{0x2f}...)
   411  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   412  
   413  	return string(b)
   414  }
   415  
   416  // FmtDateMedium returns the medium date representation of 't' for 'zh_Hant'
   417  func (zh *zh_Hant) FmtDateMedium(t time.Time) string {
   418  
   419  	b := make([]byte, 0, 32)
   420  
   421  	if t.Year() > 0 {
   422  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   423  	} else {
   424  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   425  	}
   426  
   427  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   428  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   429  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   430  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   431  	b = append(b, []byte{0xe6, 0x97, 0xa5}...)
   432  
   433  	return string(b)
   434  }
   435  
   436  // FmtDateLong returns the long date representation of 't' for 'zh_Hant'
   437  func (zh *zh_Hant) FmtDateLong(t time.Time) string {
   438  
   439  	b := make([]byte, 0, 32)
   440  
   441  	if t.Year() > 0 {
   442  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   443  	} else {
   444  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   445  	}
   446  
   447  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   448  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   449  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   450  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   451  	b = append(b, []byte{0xe6, 0x97, 0xa5}...)
   452  
   453  	return string(b)
   454  }
   455  
   456  // FmtDateFull returns the full date representation of 't' for 'zh_Hant'
   457  func (zh *zh_Hant) FmtDateFull(t time.Time) string {
   458  
   459  	b := make([]byte, 0, 32)
   460  
   461  	if t.Year() > 0 {
   462  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   463  	} else {
   464  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   465  	}
   466  
   467  	b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
   468  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   469  	b = append(b, []byte{0xe6, 0x9c, 0x88}...)
   470  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   471  	b = append(b, []byte{0xe6, 0x97, 0xa5, 0x20}...)
   472  	b = append(b, zh.daysWide[t.Weekday()]...)
   473  
   474  	return string(b)
   475  }
   476  
   477  // FmtTimeShort returns the short time representation of 't' for 'zh_Hant'
   478  func (zh *zh_Hant) FmtTimeShort(t time.Time) string {
   479  
   480  	b := make([]byte, 0, 32)
   481  
   482  	if t.Hour() < 12 {
   483  		b = append(b, zh.periodsAbbreviated[0]...)
   484  	} else {
   485  		b = append(b, zh.periodsAbbreviated[1]...)
   486  	}
   487  
   488  	h := t.Hour()
   489  
   490  	if h > 12 {
   491  		h -= 12
   492  	}
   493  
   494  	b = strconv.AppendInt(b, int64(h), 10)
   495  	b = append(b, zh.timeSeparator...)
   496  
   497  	if t.Minute() < 10 {
   498  		b = append(b, '0')
   499  	}
   500  
   501  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   502  
   503  	return string(b)
   504  }
   505  
   506  // FmtTimeMedium returns the medium time representation of 't' for 'zh_Hant'
   507  func (zh *zh_Hant) FmtTimeMedium(t time.Time) string {
   508  
   509  	b := make([]byte, 0, 32)
   510  
   511  	if t.Hour() < 12 {
   512  		b = append(b, zh.periodsAbbreviated[0]...)
   513  	} else {
   514  		b = append(b, zh.periodsAbbreviated[1]...)
   515  	}
   516  
   517  	h := t.Hour()
   518  
   519  	if h > 12 {
   520  		h -= 12
   521  	}
   522  
   523  	b = strconv.AppendInt(b, int64(h), 10)
   524  	b = append(b, zh.timeSeparator...)
   525  
   526  	if t.Minute() < 10 {
   527  		b = append(b, '0')
   528  	}
   529  
   530  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   531  	b = append(b, zh.timeSeparator...)
   532  
   533  	if t.Second() < 10 {
   534  		b = append(b, '0')
   535  	}
   536  
   537  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   538  
   539  	return string(b)
   540  }
   541  
   542  // FmtTimeLong returns the long time representation of 't' for 'zh_Hant'
   543  func (zh *zh_Hant) FmtTimeLong(t time.Time) string {
   544  
   545  	b := make([]byte, 0, 32)
   546  
   547  	if t.Hour() < 12 {
   548  		b = append(b, zh.periodsAbbreviated[0]...)
   549  	} else {
   550  		b = append(b, zh.periodsAbbreviated[1]...)
   551  	}
   552  
   553  	h := t.Hour()
   554  
   555  	if h > 12 {
   556  		h -= 12
   557  	}
   558  
   559  	b = strconv.AppendInt(b, int64(h), 10)
   560  	b = append(b, zh.timeSeparator...)
   561  
   562  	if t.Minute() < 10 {
   563  		b = append(b, '0')
   564  	}
   565  
   566  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   567  	b = append(b, zh.timeSeparator...)
   568  
   569  	if t.Second() < 10 {
   570  		b = append(b, '0')
   571  	}
   572  
   573  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   574  	b = append(b, []byte{0x20, 0x5b}...)
   575  
   576  	tz, _ := t.Zone()
   577  	b = append(b, tz...)
   578  
   579  	b = append(b, []byte{0x5d}...)
   580  
   581  	return string(b)
   582  }
   583  
   584  // FmtTimeFull returns the full time representation of 't' for 'zh_Hant'
   585  func (zh *zh_Hant) FmtTimeFull(t time.Time) string {
   586  
   587  	b := make([]byte, 0, 32)
   588  
   589  	if t.Hour() < 12 {
   590  		b = append(b, zh.periodsAbbreviated[0]...)
   591  	} else {
   592  		b = append(b, zh.periodsAbbreviated[1]...)
   593  	}
   594  
   595  	h := t.Hour()
   596  
   597  	if h > 12 {
   598  		h -= 12
   599  	}
   600  
   601  	b = strconv.AppendInt(b, int64(h), 10)
   602  	b = append(b, zh.timeSeparator...)
   603  
   604  	if t.Minute() < 10 {
   605  		b = append(b, '0')
   606  	}
   607  
   608  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   609  	b = append(b, zh.timeSeparator...)
   610  
   611  	if t.Second() < 10 {
   612  		b = append(b, '0')
   613  	}
   614  
   615  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   616  	b = append(b, []byte{0x20, 0x5b}...)
   617  
   618  	tz, _ := t.Zone()
   619  
   620  	if btz, ok := zh.timezones[tz]; ok {
   621  		b = append(b, btz...)
   622  	} else {
   623  		b = append(b, tz...)
   624  	}
   625  
   626  	b = append(b, []byte{0x5d}...)
   627  
   628  	return string(b)
   629  }
   630  

View as plain text