th_TH.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. package th_TH
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type th_TH struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyNegativePrefix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'th_TH' locale
  41. func New() locales.Translator {
  42. return &th_TH{
  43. locale: "th_TH",
  44. pluralsCardinal: []locales.PluralRule{6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{6},
  47. decimal: ".",
  48. group: ",",
  49. minus: "-",
  50. percent: "%",
  51. perMille: "‰",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. 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", "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", "UZS", "VEB", "VEF", "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"},
  55. currencyNegativePrefix: "(",
  56. currencyNegativeSuffix: ")",
  57. monthsAbbreviated: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."},
  58. monthsNarrow: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."},
  59. monthsWide: []string{"", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"},
  60. daysAbbreviated: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."},
  61. daysNarrow: []string{"อา", "จ", "อ", "พ", "พฤ", "ศ", "ส"},
  62. daysShort: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."},
  63. daysWide: []string{"วันอาทิตย์", "วันจันทร์", "วันอังคาร", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"},
  64. periodsAbbreviated: []string{"ก่อนเที่ยง", "หลังเที่ยง"},
  65. periodsNarrow: []string{"a", "p"},
  66. periodsWide: []string{"ก่อนเที่ยง", "หลังเที่ยง"},
  67. erasAbbreviated: []string{"ปีก่อน ค.ศ.", "ค.ศ."},
  68. erasNarrow: []string{"ก่อน ค.ศ.", "ค.ศ."},
  69. erasWide: []string{"ปีก่อนคริสต์ศักราช", "คริสต์ศักราช"},
  70. timezones: map[string]string{"AST": "เวลามาตรฐานแอตแลนติก", "SAST": "เวลาแอฟริกาใต้", "ACWDT": "เวลาออมแสงทางตะวันตกตอนกลางของออสเตรเลีย", "LHST": "เวลามาตรฐานลอร์ดโฮว์", "HADT": "เวลาออมแสงฮาวาย-อะลูเชียน", "UYST": "เวลาฤดูร้อนอุรุกวัย", "MDT": "เวลาออมแสงแถบภูเขาในอเมริกาเหนือ", "BT": "เวลาภูฏาน", "IST": "เวลาอินเดีย", "HNPM": "เวลามาตรฐานแซงปีแยร์และมีเกอลง", "HNNOMX": "เวลามาตรฐานเม็กซิโกตะวันตกเฉียงเหนือ", "WIT": "เวลาอินโดนีเซียฝั่งตะวันออก", "WITA": "เวลาอินโดนีเซียตอนกลาง", "CLT": "เวลามาตรฐานชิลี", "CHADT": "เวลาออมแสงแชทัม", "PDT": "เวลาออมแสงแปซิฟิกในอเมริกาเหนือ", "AWST": "เวลามาตรฐานทางตะวันตกของออสเตรเลีย", "WEZ": "เวลามาตรฐานยุโรปตะวันตก", "JST": "เวลามาตรฐานญี่ปุ่น", "EDT": "เวลาออมแสงทางตะวันออกในอเมริกาเหนือ", "HEEG": "เวลาฤดูร้อนกรีนแลนด์ตะวันออก", "TMT": "เวลามาตรฐานเติร์กเมนิสถาน", "TMST": "เวลาฤดูร้อนเติร์กเมนิสถาน", "HAST": "เวลามาตรฐานฮาวาย-อะลูเชียน", "CDT": "เวลาออมแสงตอนกลางในอเมริกาเหนือ", "NZDT": "เวลาออมแสงนิวซีแลนด์", "COST": "เวลาฤดูร้อนโคลอมเบีย", "CHAST": "เวลามาตรฐานแชทัม", "ADT": "เวลาออมแสงของแอตแลนติก", "HKT": "เวลามาตรฐานฮ่องกง", "LHDT": "เวลาออมแสงลอร์ดโฮว์", "GMT": "เวลามาตรฐานกรีนิช", "GYT": "เวลากายอานา", "AEDT": "เวลาออมแสงทางตะวันออกของออสเตรเลีย", "EST": "เวลามาตรฐานทางตะวันออกในอเมริกาเหนือ", "HKST": "เวลาฤดูร้อนฮ่องกง", "WART": "เวลามาตรฐานทางตะวันตกของอาร์เจนตินา", "AEST": "เวลามาตรฐานทางตะวันออกของออสเตรเลีย", "NZST": "เวลามาตรฐานนิวซีแลนด์", "JDT": "เวลาออมแสงญี่ปุ่น", "ACWST": "เวลามาตรฐานทางตะวันตกตอนกลางของออสเตรเลีย", "VET": "เวลาเวเนซุเอลา", "ART": "เวลามาตรฐานอาร์เจนตินา", "COT": "เวลามาตรฐานโคลอมเบีย", "HNCU": "เวลามาตรฐานคิวบา", "∅∅∅": "เวลาฤดูร้อนบราซิเลีย", "BOT": "เวลาโบลิเวีย", "HEOG": "เวลาฤดูร้อนกรีนแลนด์ตะวันตก", "HENOMX": "เวลาออมแสงเม็กซิโกตะวันตกเฉียงเหนือ", "UYT": "เวลามาตรฐานอุรุกวัย", "HECU": "เวลาออมแสงของคิวบา", "HNPMX": "เวลามาตรฐานแปซิฟิกเม็กซิโก", "MYT": "เวลามาเลเซีย", "SRT": "เวลาซูรินาเม", "OEZ": "เวลามาตรฐานยุโรปตะวันออก", "AWDT": "เวลาออมแสงทางตะวันตกของออสเตรเลีย", "WAT": "เวลามาตรฐานแอฟริกาตะวันตก", "SGT": "เวลาสิงคโปร์", "CST": "เวลามาตรฐานตอนกลางในอเมริกาเหนือ", "PST": "เวลามาตรฐานแปซิฟิกในอเมริกาเหนือ", "ECT": "เวลาเอกวาดอร์", "EAT": "เวลาแอฟริกาตะวันออก", "CLST": "เวลาฤดูร้อนชิลี", "ChST": "เวลาชามอร์โร", "HEPMX": "เวลาออมแสงแปซิฟิกเม็กซิโก", "WAST": "เวลาฤดูร้อนแอฟริกาตะวันตก", "HAT": "เวลาออมแสงนิวฟันด์แลนด์", "WIB": "เวลาอินโดนีเซียฝั่งตะวันตก", "AKST": "เวลามาตรฐานอะแลสกา", "ACDT": "เวลาออมแสงทางตอนกลางของออสเตรเลีย", "MEZ": "เวลามาตรฐานยุโรปกลาง", "WARST": "เวลาฤดูร้อนทางตะวันตกของอาร์เจนตินา", "HNT": "เวลามาตรฐานนิวฟันด์แลนด์", "MST": "เวลามาตรฐานแถบภูเขาในอเมริกาเหนือ", "WESZ": "เวลาฤดูร้อนยุโรปตะวันตก", "AKDT": "เวลาออมแสงของอะแลสกา", "HNOG": "เวลามาตรฐานกรีนแลนด์ตะวันตก", "CAT": "เวลาแอฟริกากลาง", "OESZ": "เวลาฤดูร้อนยุโรปตะวันออก", "ARST": "เวลาฤดูร้อนอาร์เจนตินา", "GFT": "เวลาเฟรนช์เกียนา", "ACST": "เวลามาตรฐานทางตอนกลางของออสเตรเลีย", "HNEG": "เวลามาตรฐานกรีนแลนด์ตะวันออก", "MESZ": "เวลาฤดูร้อนยุโรปกลาง", "HEPM": "เวลาออมแสงของแซงปีแยร์และมีเกอลง"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (th *th_TH) Locale() string {
  75. return th.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'th_TH'
  78. func (th *th_TH) PluralsCardinal() []locales.PluralRule {
  79. return th.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'th_TH'
  82. func (th *th_TH) PluralsOrdinal() []locales.PluralRule {
  83. return th.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'th_TH'
  86. func (th *th_TH) PluralsRange() []locales.PluralRule {
  87. return th.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'th_TH'
  90. func (th *th_TH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. return locales.PluralRuleOther
  92. }
  93. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'th_TH'
  94. func (th *th_TH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. return locales.PluralRuleOther
  96. }
  97. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'th_TH'
  98. func (th *th_TH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  99. return locales.PluralRuleOther
  100. }
  101. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  102. func (th *th_TH) MonthAbbreviated(month time.Month) string {
  103. return th.monthsAbbreviated[month]
  104. }
  105. // MonthsAbbreviated returns the locales abbreviated months
  106. func (th *th_TH) MonthsAbbreviated() []string {
  107. return th.monthsAbbreviated[1:]
  108. }
  109. // MonthNarrow returns the locales narrow month given the 'month' provided
  110. func (th *th_TH) MonthNarrow(month time.Month) string {
  111. return th.monthsNarrow[month]
  112. }
  113. // MonthsNarrow returns the locales narrow months
  114. func (th *th_TH) MonthsNarrow() []string {
  115. return th.monthsNarrow[1:]
  116. }
  117. // MonthWide returns the locales wide month given the 'month' provided
  118. func (th *th_TH) MonthWide(month time.Month) string {
  119. return th.monthsWide[month]
  120. }
  121. // MonthsWide returns the locales wide months
  122. func (th *th_TH) MonthsWide() []string {
  123. return th.monthsWide[1:]
  124. }
  125. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  126. func (th *th_TH) WeekdayAbbreviated(weekday time.Weekday) string {
  127. return th.daysAbbreviated[weekday]
  128. }
  129. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  130. func (th *th_TH) WeekdaysAbbreviated() []string {
  131. return th.daysAbbreviated
  132. }
  133. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  134. func (th *th_TH) WeekdayNarrow(weekday time.Weekday) string {
  135. return th.daysNarrow[weekday]
  136. }
  137. // WeekdaysNarrow returns the locales narrow weekdays
  138. func (th *th_TH) WeekdaysNarrow() []string {
  139. return th.daysNarrow
  140. }
  141. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  142. func (th *th_TH) WeekdayShort(weekday time.Weekday) string {
  143. return th.daysShort[weekday]
  144. }
  145. // WeekdaysShort returns the locales short weekdays
  146. func (th *th_TH) WeekdaysShort() []string {
  147. return th.daysShort
  148. }
  149. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  150. func (th *th_TH) WeekdayWide(weekday time.Weekday) string {
  151. return th.daysWide[weekday]
  152. }
  153. // WeekdaysWide returns the locales wide weekdays
  154. func (th *th_TH) WeekdaysWide() []string {
  155. return th.daysWide
  156. }
  157. // Decimal returns the decimal point of number
  158. func (th *th_TH) Decimal() string {
  159. return th.decimal
  160. }
  161. // Group returns the group of number
  162. func (th *th_TH) Group() string {
  163. return th.group
  164. }
  165. // Group returns the minus sign of number
  166. func (th *th_TH) Minus() string {
  167. return th.minus
  168. }
  169. // FmtNumber returns 'num' with digits/precision of 'v' for 'th_TH' and handles both Whole and Real numbers based on 'v'
  170. func (th *th_TH) FmtNumber(num float64, v uint64) string {
  171. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  172. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  173. count := 0
  174. inWhole := v == 0
  175. b := make([]byte, 0, l)
  176. for i := len(s) - 1; i >= 0; i-- {
  177. if s[i] == '.' {
  178. b = append(b, th.decimal[0])
  179. inWhole = true
  180. continue
  181. }
  182. if inWhole {
  183. if count == 3 {
  184. b = append(b, th.group[0])
  185. count = 1
  186. } else {
  187. count++
  188. }
  189. }
  190. b = append(b, s[i])
  191. }
  192. if num < 0 {
  193. b = append(b, th.minus[0])
  194. }
  195. // reverse
  196. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  197. b[i], b[j] = b[j], b[i]
  198. }
  199. return string(b)
  200. }
  201. // FmtPercent returns 'num' with digits/precision of 'v' for 'th_TH' and handles both Whole and Real numbers based on 'v'
  202. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  203. func (th *th_TH) FmtPercent(num float64, v uint64) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. l := len(s) + 3
  206. b := make([]byte, 0, l)
  207. for i := len(s) - 1; i >= 0; i-- {
  208. if s[i] == '.' {
  209. b = append(b, th.decimal[0])
  210. continue
  211. }
  212. b = append(b, s[i])
  213. }
  214. if num < 0 {
  215. b = append(b, th.minus[0])
  216. }
  217. // reverse
  218. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  219. b[i], b[j] = b[j], b[i]
  220. }
  221. b = append(b, th.percent...)
  222. return string(b)
  223. }
  224. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'th_TH'
  225. func (th *th_TH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  226. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  227. symbol := th.currencies[currency]
  228. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  229. count := 0
  230. inWhole := v == 0
  231. b := make([]byte, 0, l)
  232. for i := len(s) - 1; i >= 0; i-- {
  233. if s[i] == '.' {
  234. b = append(b, th.decimal[0])
  235. inWhole = true
  236. continue
  237. }
  238. if inWhole {
  239. if count == 3 {
  240. b = append(b, th.group[0])
  241. count = 1
  242. } else {
  243. count++
  244. }
  245. }
  246. b = append(b, s[i])
  247. }
  248. for j := len(symbol) - 1; j >= 0; j-- {
  249. b = append(b, symbol[j])
  250. }
  251. if num < 0 {
  252. b = append(b, th.minus[0])
  253. }
  254. // reverse
  255. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  256. b[i], b[j] = b[j], b[i]
  257. }
  258. if int(v) < 2 {
  259. if v == 0 {
  260. b = append(b, th.decimal...)
  261. }
  262. for i := 0; i < 2-int(v); i++ {
  263. b = append(b, '0')
  264. }
  265. }
  266. return string(b)
  267. }
  268. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'th_TH'
  269. // in accounting notation.
  270. func (th *th_TH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  271. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  272. symbol := th.currencies[currency]
  273. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  274. count := 0
  275. inWhole := v == 0
  276. b := make([]byte, 0, l)
  277. for i := len(s) - 1; i >= 0; i-- {
  278. if s[i] == '.' {
  279. b = append(b, th.decimal[0])
  280. inWhole = true
  281. continue
  282. }
  283. if inWhole {
  284. if count == 3 {
  285. b = append(b, th.group[0])
  286. count = 1
  287. } else {
  288. count++
  289. }
  290. }
  291. b = append(b, s[i])
  292. }
  293. if num < 0 {
  294. for j := len(symbol) - 1; j >= 0; j-- {
  295. b = append(b, symbol[j])
  296. }
  297. b = append(b, th.currencyNegativePrefix[0])
  298. } else {
  299. for j := len(symbol) - 1; j >= 0; j-- {
  300. b = append(b, symbol[j])
  301. }
  302. }
  303. // reverse
  304. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  305. b[i], b[j] = b[j], b[i]
  306. }
  307. if int(v) < 2 {
  308. if v == 0 {
  309. b = append(b, th.decimal...)
  310. }
  311. for i := 0; i < 2-int(v); i++ {
  312. b = append(b, '0')
  313. }
  314. }
  315. if num < 0 {
  316. b = append(b, th.currencyNegativeSuffix...)
  317. }
  318. return string(b)
  319. }
  320. // FmtDateShort returns the short date representation of 't' for 'th_TH'
  321. func (th *th_TH) FmtDateShort(t time.Time) string {
  322. b := make([]byte, 0, 32)
  323. b = strconv.AppendInt(b, int64(t.Day()), 10)
  324. b = append(b, []byte{0x2f}...)
  325. b = strconv.AppendInt(b, int64(t.Month()), 10)
  326. b = append(b, []byte{0x2f}...)
  327. if t.Year() > 9 {
  328. b = append(b, strconv.Itoa(t.Year())[2:]...)
  329. } else {
  330. b = append(b, strconv.Itoa(t.Year())[1:]...)
  331. }
  332. return string(b)
  333. }
  334. // FmtDateMedium returns the medium date representation of 't' for 'th_TH'
  335. func (th *th_TH) FmtDateMedium(t time.Time) string {
  336. b := make([]byte, 0, 32)
  337. b = strconv.AppendInt(b, int64(t.Day()), 10)
  338. b = append(b, []byte{0x20}...)
  339. b = append(b, th.monthsAbbreviated[t.Month()]...)
  340. b = append(b, []byte{0x20}...)
  341. if t.Year() > 0 {
  342. b = strconv.AppendInt(b, int64(t.Year()), 10)
  343. } else {
  344. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  345. }
  346. return string(b)
  347. }
  348. // FmtDateLong returns the long date representation of 't' for 'th_TH'
  349. func (th *th_TH) FmtDateLong(t time.Time) string {
  350. b := make([]byte, 0, 32)
  351. b = strconv.AppendInt(b, int64(t.Day()), 10)
  352. b = append(b, []byte{0x20}...)
  353. b = append(b, th.monthsWide[t.Month()]...)
  354. b = append(b, []byte{0x20}...)
  355. if t.Year() < 0 {
  356. b = append(b, th.erasAbbreviated[0]...)
  357. } else {
  358. b = append(b, th.erasAbbreviated[1]...)
  359. }
  360. b = append(b, []byte{0x20}...)
  361. if t.Year() > 0 {
  362. b = strconv.AppendInt(b, int64(t.Year()), 10)
  363. } else {
  364. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  365. }
  366. return string(b)
  367. }
  368. // FmtDateFull returns the full date representation of 't' for 'th_TH'
  369. func (th *th_TH) FmtDateFull(t time.Time) string {
  370. b := make([]byte, 0, 32)
  371. b = append(b, th.daysWide[t.Weekday()]...)
  372. b = append(b, []byte{0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0xe0, 0xb9, 0x88, 0x20}...)
  373. b = strconv.AppendInt(b, int64(t.Day()), 10)
  374. b = append(b, []byte{0x20}...)
  375. b = append(b, th.monthsWide[t.Month()]...)
  376. b = append(b, []byte{0x20}...)
  377. if t.Year() < 0 {
  378. b = append(b, th.erasWide[0]...)
  379. } else {
  380. b = append(b, th.erasWide[1]...)
  381. }
  382. b = append(b, []byte{0x20}...)
  383. if t.Year() > 0 {
  384. b = strconv.AppendInt(b, int64(t.Year()), 10)
  385. } else {
  386. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  387. }
  388. return string(b)
  389. }
  390. // FmtTimeShort returns the short time representation of 't' for 'th_TH'
  391. func (th *th_TH) FmtTimeShort(t time.Time) string {
  392. b := make([]byte, 0, 32)
  393. if t.Hour() < 10 {
  394. b = append(b, '0')
  395. }
  396. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  397. b = append(b, th.timeSeparator...)
  398. if t.Minute() < 10 {
  399. b = append(b, '0')
  400. }
  401. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  402. return string(b)
  403. }
  404. // FmtTimeMedium returns the medium time representation of 't' for 'th_TH'
  405. func (th *th_TH) FmtTimeMedium(t time.Time) string {
  406. b := make([]byte, 0, 32)
  407. if t.Hour() < 10 {
  408. b = append(b, '0')
  409. }
  410. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  411. b = append(b, th.timeSeparator...)
  412. if t.Minute() < 10 {
  413. b = append(b, '0')
  414. }
  415. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  416. b = append(b, th.timeSeparator...)
  417. if t.Second() < 10 {
  418. b = append(b, '0')
  419. }
  420. b = strconv.AppendInt(b, int64(t.Second()), 10)
  421. return string(b)
  422. }
  423. // FmtTimeLong returns the long time representation of 't' for 'th_TH'
  424. func (th *th_TH) FmtTimeLong(t time.Time) string {
  425. b := make([]byte, 0, 32)
  426. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  427. b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...)
  428. if t.Minute() < 10 {
  429. b = append(b, '0')
  430. }
  431. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  432. b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
  433. if t.Second() < 10 {
  434. b = append(b, '0')
  435. }
  436. b = strconv.AppendInt(b, int64(t.Second()), 10)
  437. b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
  438. tz, _ := t.Zone()
  439. b = append(b, tz...)
  440. return string(b)
  441. }
  442. // FmtTimeFull returns the full time representation of 't' for 'th_TH'
  443. func (th *th_TH) FmtTimeFull(t time.Time) string {
  444. b := make([]byte, 0, 32)
  445. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  446. b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...)
  447. if t.Minute() < 10 {
  448. b = append(b, '0')
  449. }
  450. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  451. b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
  452. if t.Second() < 10 {
  453. b = append(b, '0')
  454. }
  455. b = strconv.AppendInt(b, int64(t.Second()), 10)
  456. b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)
  457. tz, _ := t.Zone()
  458. if btz, ok := th.timezones[tz]; ok {
  459. b = append(b, btz...)
  460. } else {
  461. b = append(b, tz...)
  462. }
  463. return string(b)
  464. }