...

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

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

     1  package th_TH
     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 th_TH 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 'th_TH' locale
    45  func New() locales.Translator {
    46  	return &th_TH{
    47  		locale:                 "th_TH",
    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", "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"},
    59  		currencyNegativePrefix: "(",
    60  		currencyNegativeSuffix: ")",
    61  		monthsAbbreviated:      []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."},
    62  		monthsNarrow:           []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."},
    63  		monthsWide:             []string{"", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"},
    64  		daysAbbreviated:        []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."},
    65  		daysNarrow:             []string{"อา", "จ", "อ", "พ", "พฤ", "ศ", "ส"},
    66  		daysShort:              []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."},
    67  		daysWide:               []string{"วันอาทิตย์", "วันจันทร์", "วันอังคาร", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"},
    68  		periodsAbbreviated:     []string{"ก่อนเที่ยง", "หลังเที่ยง"},
    69  		periodsNarrow:          []string{"a", "p"},
    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 (th *th_TH) Locale() string {
    80  	return th.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'th_TH'
    84  func (th *th_TH) PluralsCardinal() []locales.PluralRule {
    85  	return th.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'th_TH'
    89  func (th *th_TH) PluralsOrdinal() []locales.PluralRule {
    90  	return th.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'th_TH'
    94  func (th *th_TH) PluralsRange() []locales.PluralRule {
    95  	return th.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'th_TH'
    99  func (th *th_TH) 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 'th_TH'
   104  func (th *th_TH) 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 'th_TH'
   109  func (th *th_TH) 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 (th *th_TH) MonthAbbreviated(month time.Month) string {
   115  	return th.monthsAbbreviated[month]
   116  }
   117  
   118  // MonthsAbbreviated returns the locales abbreviated months
   119  func (th *th_TH) MonthsAbbreviated() []string {
   120  	return th.monthsAbbreviated[1:]
   121  }
   122  
   123  // MonthNarrow returns the locales narrow month given the 'month' provided
   124  func (th *th_TH) MonthNarrow(month time.Month) string {
   125  	return th.monthsNarrow[month]
   126  }
   127  
   128  // MonthsNarrow returns the locales narrow months
   129  func (th *th_TH) MonthsNarrow() []string {
   130  	return th.monthsNarrow[1:]
   131  }
   132  
   133  // MonthWide returns the locales wide month given the 'month' provided
   134  func (th *th_TH) MonthWide(month time.Month) string {
   135  	return th.monthsWide[month]
   136  }
   137  
   138  // MonthsWide returns the locales wide months
   139  func (th *th_TH) MonthsWide() []string {
   140  	return th.monthsWide[1:]
   141  }
   142  
   143  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   144  func (th *th_TH) WeekdayAbbreviated(weekday time.Weekday) string {
   145  	return th.daysAbbreviated[weekday]
   146  }
   147  
   148  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   149  func (th *th_TH) WeekdaysAbbreviated() []string {
   150  	return th.daysAbbreviated
   151  }
   152  
   153  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   154  func (th *th_TH) WeekdayNarrow(weekday time.Weekday) string {
   155  	return th.daysNarrow[weekday]
   156  }
   157  
   158  // WeekdaysNarrow returns the locales narrow weekdays
   159  func (th *th_TH) WeekdaysNarrow() []string {
   160  	return th.daysNarrow
   161  }
   162  
   163  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   164  func (th *th_TH) WeekdayShort(weekday time.Weekday) string {
   165  	return th.daysShort[weekday]
   166  }
   167  
   168  // WeekdaysShort returns the locales short weekdays
   169  func (th *th_TH) WeekdaysShort() []string {
   170  	return th.daysShort
   171  }
   172  
   173  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   174  func (th *th_TH) WeekdayWide(weekday time.Weekday) string {
   175  	return th.daysWide[weekday]
   176  }
   177  
   178  // WeekdaysWide returns the locales wide weekdays
   179  func (th *th_TH) WeekdaysWide() []string {
   180  	return th.daysWide
   181  }
   182  
   183  // Decimal returns the decimal point of number
   184  func (th *th_TH) Decimal() string {
   185  	return th.decimal
   186  }
   187  
   188  // Group returns the group of number
   189  func (th *th_TH) Group() string {
   190  	return th.group
   191  }
   192  
   193  // Group returns the minus sign of number
   194  func (th *th_TH) Minus() string {
   195  	return th.minus
   196  }
   197  
   198  // FmtNumber returns 'num' with digits/precision of 'v' for 'th_TH' and handles both Whole and Real numbers based on 'v'
   199  func (th *th_TH) 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, th.decimal[0])
   211  			inWhole = true
   212  			continue
   213  		}
   214  
   215  		if inWhole {
   216  			if count == 3 {
   217  				b = append(b, th.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, th.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 'th_TH' 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 (th *th_TH) 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, th.decimal[0])
   250  			continue
   251  		}
   252  
   253  		b = append(b, s[i])
   254  	}
   255  
   256  	if num < 0 {
   257  		b = append(b, th.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, th.percent...)
   266  
   267  	return string(b)
   268  }
   269  
   270  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'th_TH'
   271  func (th *th_TH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   272  
   273  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   274  	symbol := th.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, th.decimal[0])
   284  			inWhole = true
   285  			continue
   286  		}
   287  
   288  		if inWhole {
   289  			if count == 3 {
   290  				b = append(b, th.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, th.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, th.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 'th_TH'
   328  // in accounting notation.
   329  func (th *th_TH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   330  
   331  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   332  	symbol := th.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, th.decimal[0])
   342  			inWhole = true
   343  			continue
   344  		}
   345  
   346  		if inWhole {
   347  			if count == 3 {
   348  				b = append(b, th.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, th.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, th.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, th.currencyNegativeSuffix...)
   392  	}
   393  
   394  	return string(b)
   395  }
   396  
   397  // FmtDateShort returns the short date representation of 't' for 'th_TH'
   398  func (th *th_TH) FmtDateShort(t time.Time) string {
   399  
   400  	b := make([]byte, 0, 32)
   401  
   402  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   403  	b = append(b, []byte{0x2f}...)
   404  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   405  	b = append(b, []byte{0x2f}...)
   406  
   407  	if t.Year() > 9 {
   408  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   409  	} else {
   410  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   411  	}
   412  
   413  	return string(b)
   414  }
   415  
   416  // FmtDateMedium returns the medium date representation of 't' for 'th_TH'
   417  func (th *th_TH) FmtDateMedium(t time.Time) string {
   418  
   419  	b := make([]byte, 0, 32)
   420  
   421  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   422  	b = append(b, []byte{0x20}...)
   423  	b = append(b, th.monthsAbbreviated[t.Month()]...)
   424  	b = append(b, []byte{0x20}...)
   425  
   426  	if t.Year() > 0 {
   427  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   428  	} else {
   429  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   430  	}
   431  
   432  	return string(b)
   433  }
   434  
   435  // FmtDateLong returns the long date representation of 't' for 'th_TH'
   436  func (th *th_TH) FmtDateLong(t time.Time) string {
   437  
   438  	b := make([]byte, 0, 32)
   439  
   440  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   441  	b = append(b, []byte{0x20}...)
   442  	b = append(b, th.monthsWide[t.Month()]...)
   443  	b = append(b, []byte{0x20}...)
   444  
   445  	if t.Year() < 0 {
   446  		b = append(b, th.erasAbbreviated[0]...)
   447  	} else {
   448  		b = append(b, th.erasAbbreviated[1]...)
   449  	}
   450  
   451  	b = append(b, []byte{0x20}...)
   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  	return string(b)
   460  }
   461  
   462  // FmtDateFull returns the full date representation of 't' for 'th_TH'
   463  func (th *th_TH) FmtDateFull(t time.Time) string {
   464  
   465  	b := make([]byte, 0, 32)
   466  
   467  	b = append(b, th.daysWide[t.Weekday()]...)
   468  	b = append(b, []byte{0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0xe0, 0xb9, 0x88, 0x20}...)
   469  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   470  	b = append(b, []byte{0x20}...)
   471  	b = append(b, th.monthsWide[t.Month()]...)
   472  	b = append(b, []byte{0x20}...)
   473  
   474  	if t.Year() < 0 {
   475  		b = append(b, th.erasWide[0]...)
   476  	} else {
   477  		b = append(b, th.erasWide[1]...)
   478  	}
   479  
   480  	b = append(b, []byte{0x20}...)
   481  
   482  	if t.Year() > 0 {
   483  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   484  	} else {
   485  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   486  	}
   487  
   488  	return string(b)
   489  }
   490  
   491  // FmtTimeShort returns the short time representation of 't' for 'th_TH'
   492  func (th *th_TH) FmtTimeShort(t time.Time) string {
   493  
   494  	b := make([]byte, 0, 32)
   495  
   496  	if t.Hour() < 10 {
   497  		b = append(b, '0')
   498  	}
   499  
   500  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   501  	b = append(b, th.timeSeparator...)
   502  
   503  	if t.Minute() < 10 {
   504  		b = append(b, '0')
   505  	}
   506  
   507  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   508  
   509  	return string(b)
   510  }
   511  
   512  // FmtTimeMedium returns the medium time representation of 't' for 'th_TH'
   513  func (th *th_TH) FmtTimeMedium(t time.Time) string {
   514  
   515  	b := make([]byte, 0, 32)
   516  
   517  	if t.Hour() < 10 {
   518  		b = append(b, '0')
   519  	}
   520  
   521  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   522  	b = append(b, th.timeSeparator...)
   523  
   524  	if t.Minute() < 10 {
   525  		b = append(b, '0')
   526  	}
   527  
   528  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   529  	b = append(b, th.timeSeparator...)
   530  
   531  	if t.Second() < 10 {
   532  		b = append(b, '0')
   533  	}
   534  
   535  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   536  
   537  	return string(b)
   538  }
   539  
   540  // FmtTimeLong returns the long time representation of 't' for 'th_TH'
   541  func (th *th_TH) FmtTimeLong(t time.Time) string {
   542  
   543  	b := make([]byte, 0, 32)
   544  
   545  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   546  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...)
   547  
   548  	if t.Minute() < 10 {
   549  		b = append(b, '0')
   550  	}
   551  
   552  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   553  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
   554  
   555  	if t.Second() < 10 {
   556  		b = append(b, '0')
   557  	}
   558  
   559  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   560  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
   561  
   562  	tz, _ := t.Zone()
   563  	b = append(b, tz...)
   564  
   565  	return string(b)
   566  }
   567  
   568  // FmtTimeFull returns the full time representation of 't' for 'th_TH'
   569  func (th *th_TH) FmtTimeFull(t time.Time) string {
   570  
   571  	b := make([]byte, 0, 32)
   572  
   573  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   574  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...)
   575  
   576  	if t.Minute() < 10 {
   577  		b = append(b, '0')
   578  	}
   579  
   580  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   581  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
   582  
   583  	if t.Second() < 10 {
   584  		b = append(b, '0')
   585  	}
   586  
   587  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   588  	b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
   589  
   590  	tz, _ := t.Zone()
   591  
   592  	if btz, ok := th.timezones[tz]; ok {
   593  		b = append(b, btz...)
   594  	} else {
   595  		b = append(b, tz...)
   596  	}
   597  
   598  	return string(b)
   599  }
   600  

View as plain text