tg_TJ.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. package tg_TJ
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type tg_TJ 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. currencyPositiveSuffix 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 'tg_TJ' locale
  41. func New() locales.Translator {
  42. return &tg_TJ{
  43. locale: "tg_TJ",
  44. pluralsCardinal: nil,
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  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. currencyPositiveSuffix: " ",
  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. periodsWide: []string{"пе. чо.", "па. чо."},
  66. erasAbbreviated: []string{"ПеМ", "ПаМ"},
  67. erasNarrow: []string{"", ""},
  68. erasWide: []string{"Пеш аз милод", "ПаМ"},
  69. timezones: map[string]string{"WIT": "WIT", "HNCU": "HNCU", "CDT": "Вақти рӯзонаи марказӣ", "AEST": "AEST", "CAT": "CAT", "UYST": "UYST", "GFT": "GFT", "NZST": "NZST", "AKDT": "AKDT", "HNEG": "HNEG", "WART": "WART", "HAT": "HAT", "ChST": "ChST", "HNPMX": "HNPMX", "WAST": "WAST", "WEZ": "Вақти стандартии аврупоии ғарбӣ", "HENOMX": "HENOMX", "OESZ": "Вақти тобистонаи аврупоии шарқӣ", "AWDT": "AWDT", "AEDT": "AEDT", "SAST": "SAST", "WAT": "WAT", "EST": "Вақти стандартии шарқӣ", "TMST": "TMST", "HADT": "HADT", "UYT": "UYT", "JST": "JST", "JDT": "JDT", "TMT": "TMT", "∅∅∅": "∅∅∅", "CST": "Вақти стандартии марказӣ", "PST": "Вақти стандартии Уқёнуси Ором", "HEPMX": "HEPMX", "AST": "Вақти стандартии атлантикӣ", "ADT": "Вақти рӯзонаи атлантикӣ", "WIB": "WIB", "MYT": "MYT", "HNOG": "HNOG", "MEZ": "Вақти стандартии аврупоии марказӣ", "LHST": "LHST", "HKST": "HKST", "GMT": "Ба вақти Гринвич", "HEOG": "HEOG", "EDT": "Вақти рӯзонаи шарқӣ", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "COT": "COT", "COST": "COST", "GYT": "GYT", "CHADT": "CHADT", "BT": "BT", "ACST": "ACST", "ACWDT": "ACWDT", "VET": "VET", "MDT": "MDT", "NZDT": "NZDT", "AKST": "AKST", "IST": "IST", "HAST": "HAST", "ARST": "ARST", "PDT": "Вақти рӯзонаи Уқёнуси Ором", "AWST": "AWST", "HNT": "HNT", "MST": "MST", "CLT": "CLT", "SGT": "SGT", "HKT": "HKT", "WITA": "WITA", "CLST": "CLST", "CHAST": "CHAST", "WESZ": "Вақти тобистонаи аврупоии ғарбӣ", "MESZ": "Вақти тобистонаи аврупоии марказӣ", "WARST": "WARST", "HNPM": "HNPM", "OEZ": "Вақти стандартии аврупоии шарқӣ", "ART": "ART", "ACWST": "ACWST", "LHDT": "LHDT", "HEPM": "HEPM", "SRT": "SRT", "EAT": "EAT", "HECU": "HECU", "BOT": "BOT", "ECT": "ECT", "HEEG": "HEEG"},
  70. }
  71. }
  72. // Locale returns the current translators string locale
  73. func (tg *tg_TJ) Locale() string {
  74. return tg.locale
  75. }
  76. // PluralsCardinal returns the list of cardinal plural rules associated with 'tg_TJ'
  77. func (tg *tg_TJ) PluralsCardinal() []locales.PluralRule {
  78. return tg.pluralsCardinal
  79. }
  80. // PluralsOrdinal returns the list of ordinal plural rules associated with 'tg_TJ'
  81. func (tg *tg_TJ) PluralsOrdinal() []locales.PluralRule {
  82. return tg.pluralsOrdinal
  83. }
  84. // PluralsRange returns the list of range plural rules associated with 'tg_TJ'
  85. func (tg *tg_TJ) PluralsRange() []locales.PluralRule {
  86. return tg.pluralsRange
  87. }
  88. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tg_TJ'
  89. func (tg *tg_TJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  90. return locales.PluralRuleUnknown
  91. }
  92. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tg_TJ'
  93. func (tg *tg_TJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  94. return locales.PluralRuleUnknown
  95. }
  96. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tg_TJ'
  97. func (tg *tg_TJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  98. return locales.PluralRuleUnknown
  99. }
  100. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  101. func (tg *tg_TJ) MonthAbbreviated(month time.Month) string {
  102. return tg.monthsAbbreviated[month]
  103. }
  104. // MonthsAbbreviated returns the locales abbreviated months
  105. func (tg *tg_TJ) MonthsAbbreviated() []string {
  106. return tg.monthsAbbreviated[1:]
  107. }
  108. // MonthNarrow returns the locales narrow month given the 'month' provided
  109. func (tg *tg_TJ) MonthNarrow(month time.Month) string {
  110. return tg.monthsNarrow[month]
  111. }
  112. // MonthsNarrow returns the locales narrow months
  113. func (tg *tg_TJ) MonthsNarrow() []string {
  114. return tg.monthsNarrow[1:]
  115. }
  116. // MonthWide returns the locales wide month given the 'month' provided
  117. func (tg *tg_TJ) MonthWide(month time.Month) string {
  118. return tg.monthsWide[month]
  119. }
  120. // MonthsWide returns the locales wide months
  121. func (tg *tg_TJ) MonthsWide() []string {
  122. return tg.monthsWide[1:]
  123. }
  124. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  125. func (tg *tg_TJ) WeekdayAbbreviated(weekday time.Weekday) string {
  126. return tg.daysAbbreviated[weekday]
  127. }
  128. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  129. func (tg *tg_TJ) WeekdaysAbbreviated() []string {
  130. return tg.daysAbbreviated
  131. }
  132. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  133. func (tg *tg_TJ) WeekdayNarrow(weekday time.Weekday) string {
  134. return tg.daysNarrow[weekday]
  135. }
  136. // WeekdaysNarrow returns the locales narrow weekdays
  137. func (tg *tg_TJ) WeekdaysNarrow() []string {
  138. return tg.daysNarrow
  139. }
  140. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  141. func (tg *tg_TJ) WeekdayShort(weekday time.Weekday) string {
  142. return tg.daysShort[weekday]
  143. }
  144. // WeekdaysShort returns the locales short weekdays
  145. func (tg *tg_TJ) WeekdaysShort() []string {
  146. return tg.daysShort
  147. }
  148. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  149. func (tg *tg_TJ) WeekdayWide(weekday time.Weekday) string {
  150. return tg.daysWide[weekday]
  151. }
  152. // WeekdaysWide returns the locales wide weekdays
  153. func (tg *tg_TJ) WeekdaysWide() []string {
  154. return tg.daysWide
  155. }
  156. // Decimal returns the decimal point of number
  157. func (tg *tg_TJ) Decimal() string {
  158. return tg.decimal
  159. }
  160. // Group returns the group of number
  161. func (tg *tg_TJ) Group() string {
  162. return tg.group
  163. }
  164. // Group returns the minus sign of number
  165. func (tg *tg_TJ) Minus() string {
  166. return tg.minus
  167. }
  168. // FmtNumber returns 'num' with digits/precision of 'v' for 'tg_TJ' and handles both Whole and Real numbers based on 'v'
  169. func (tg *tg_TJ) FmtNumber(num float64, v uint64) string {
  170. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  171. l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
  172. count := 0
  173. inWhole := v == 0
  174. b := make([]byte, 0, l)
  175. for i := len(s) - 1; i >= 0; i-- {
  176. if s[i] == '.' {
  177. b = append(b, tg.decimal[0])
  178. inWhole = true
  179. continue
  180. }
  181. if inWhole {
  182. if count == 3 {
  183. for j := len(tg.group) - 1; j >= 0; j-- {
  184. b = append(b, tg.group[j])
  185. }
  186. count = 1
  187. } else {
  188. count++
  189. }
  190. }
  191. b = append(b, s[i])
  192. }
  193. if num < 0 {
  194. b = append(b, tg.minus[0])
  195. }
  196. // reverse
  197. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  198. b[i], b[j] = b[j], b[i]
  199. }
  200. return string(b)
  201. }
  202. // FmtPercent returns 'num' with digits/precision of 'v' for 'tg_TJ' and handles both Whole and Real numbers based on 'v'
  203. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  204. func (tg *tg_TJ) FmtPercent(num float64, v uint64) string {
  205. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  206. l := len(s) + 3
  207. b := make([]byte, 0, l)
  208. for i := len(s) - 1; i >= 0; i-- {
  209. if s[i] == '.' {
  210. b = append(b, tg.decimal[0])
  211. continue
  212. }
  213. b = append(b, s[i])
  214. }
  215. if num < 0 {
  216. b = append(b, tg.minus[0])
  217. }
  218. // reverse
  219. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  220. b[i], b[j] = b[j], b[i]
  221. }
  222. b = append(b, tg.percent...)
  223. return string(b)
  224. }
  225. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tg_TJ'
  226. func (tg *tg_TJ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  227. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  228. symbol := tg.currencies[currency]
  229. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  230. count := 0
  231. inWhole := v == 0
  232. b := make([]byte, 0, l)
  233. for i := len(s) - 1; i >= 0; i-- {
  234. if s[i] == '.' {
  235. b = append(b, tg.decimal[0])
  236. inWhole = true
  237. continue
  238. }
  239. if inWhole {
  240. if count == 3 {
  241. for j := len(tg.group) - 1; j >= 0; j-- {
  242. b = append(b, tg.group[j])
  243. }
  244. count = 1
  245. } else {
  246. count++
  247. }
  248. }
  249. b = append(b, s[i])
  250. }
  251. if num < 0 {
  252. b = append(b, tg.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, tg.decimal...)
  261. }
  262. for i := 0; i < 2-int(v); i++ {
  263. b = append(b, '0')
  264. }
  265. }
  266. b = append(b, tg.currencyPositiveSuffix...)
  267. b = append(b, symbol...)
  268. return string(b)
  269. }
  270. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tg_TJ'
  271. // in accounting notation.
  272. func (tg *tg_TJ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  273. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  274. symbol := tg.currencies[currency]
  275. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  276. count := 0
  277. inWhole := v == 0
  278. b := make([]byte, 0, l)
  279. for i := len(s) - 1; i >= 0; i-- {
  280. if s[i] == '.' {
  281. b = append(b, tg.decimal[0])
  282. inWhole = true
  283. continue
  284. }
  285. if inWhole {
  286. if count == 3 {
  287. for j := len(tg.group) - 1; j >= 0; j-- {
  288. b = append(b, tg.group[j])
  289. }
  290. count = 1
  291. } else {
  292. count++
  293. }
  294. }
  295. b = append(b, s[i])
  296. }
  297. if num < 0 {
  298. b = append(b, tg.minus[0])
  299. }
  300. // reverse
  301. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  302. b[i], b[j] = b[j], b[i]
  303. }
  304. if int(v) < 2 {
  305. if v == 0 {
  306. b = append(b, tg.decimal...)
  307. }
  308. for i := 0; i < 2-int(v); i++ {
  309. b = append(b, '0')
  310. }
  311. }
  312. if num < 0 {
  313. b = append(b, tg.currencyNegativeSuffix...)
  314. b = append(b, symbol...)
  315. } else {
  316. b = append(b, tg.currencyPositiveSuffix...)
  317. b = append(b, symbol...)
  318. }
  319. return string(b)
  320. }
  321. // FmtDateShort returns the short date representation of 't' for 'tg_TJ'
  322. func (tg *tg_TJ) FmtDateShort(t time.Time) string {
  323. b := make([]byte, 0, 32)
  324. if t.Day() < 10 {
  325. b = append(b, '0')
  326. }
  327. b = strconv.AppendInt(b, int64(t.Day()), 10)
  328. b = append(b, []byte{0x2f}...)
  329. if t.Month() < 10 {
  330. b = append(b, '0')
  331. }
  332. b = strconv.AppendInt(b, int64(t.Month()), 10)
  333. b = append(b, []byte{0x2f}...)
  334. if t.Year() > 9 {
  335. b = append(b, strconv.Itoa(t.Year())[2:]...)
  336. } else {
  337. b = append(b, strconv.Itoa(t.Year())[1:]...)
  338. }
  339. return string(b)
  340. }
  341. // FmtDateMedium returns the medium date representation of 't' for 'tg_TJ'
  342. func (tg *tg_TJ) FmtDateMedium(t time.Time) string {
  343. b := make([]byte, 0, 32)
  344. if t.Day() < 10 {
  345. b = append(b, '0')
  346. }
  347. b = strconv.AppendInt(b, int64(t.Day()), 10)
  348. b = append(b, []byte{0x20}...)
  349. b = append(b, tg.monthsAbbreviated[t.Month()]...)
  350. b = append(b, []byte{0x20}...)
  351. if t.Year() > 0 {
  352. b = strconv.AppendInt(b, int64(t.Year()), 10)
  353. } else {
  354. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  355. }
  356. return string(b)
  357. }
  358. // FmtDateLong returns the long date representation of 't' for 'tg_TJ'
  359. func (tg *tg_TJ) FmtDateLong(t time.Time) string {
  360. b := make([]byte, 0, 32)
  361. if t.Day() < 10 {
  362. b = append(b, '0')
  363. }
  364. b = strconv.AppendInt(b, int64(t.Day()), 10)
  365. b = append(b, []byte{0x20}...)
  366. b = append(b, tg.monthsWide[t.Month()]...)
  367. b = append(b, []byte{0x20}...)
  368. if t.Year() > 0 {
  369. b = strconv.AppendInt(b, int64(t.Year()), 10)
  370. } else {
  371. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  372. }
  373. return string(b)
  374. }
  375. // FmtDateFull returns the full date representation of 't' for 'tg_TJ'
  376. func (tg *tg_TJ) FmtDateFull(t time.Time) string {
  377. b := make([]byte, 0, 32)
  378. b = append(b, tg.daysWide[t.Weekday()]...)
  379. b = append(b, []byte{0x2c, 0x20}...)
  380. if t.Day() < 10 {
  381. b = append(b, '0')
  382. }
  383. b = strconv.AppendInt(b, int64(t.Day()), 10)
  384. b = append(b, []byte{0x20}...)
  385. b = append(b, tg.monthsWide[t.Month()]...)
  386. b = append(b, []byte{0x20}...)
  387. if t.Year() > 0 {
  388. b = strconv.AppendInt(b, int64(t.Year()), 10)
  389. } else {
  390. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  391. }
  392. return string(b)
  393. }
  394. // FmtTimeShort returns the short time representation of 't' for 'tg_TJ'
  395. func (tg *tg_TJ) FmtTimeShort(t time.Time) string {
  396. b := make([]byte, 0, 32)
  397. if t.Hour() < 10 {
  398. b = append(b, '0')
  399. }
  400. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  401. b = append(b, tg.timeSeparator...)
  402. if t.Minute() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  406. return string(b)
  407. }
  408. // FmtTimeMedium returns the medium time representation of 't' for 'tg_TJ'
  409. func (tg *tg_TJ) FmtTimeMedium(t time.Time) string {
  410. b := make([]byte, 0, 32)
  411. if t.Hour() < 10 {
  412. b = append(b, '0')
  413. }
  414. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  415. b = append(b, tg.timeSeparator...)
  416. if t.Minute() < 10 {
  417. b = append(b, '0')
  418. }
  419. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  420. b = append(b, tg.timeSeparator...)
  421. if t.Second() < 10 {
  422. b = append(b, '0')
  423. }
  424. b = strconv.AppendInt(b, int64(t.Second()), 10)
  425. return string(b)
  426. }
  427. // FmtTimeLong returns the long time representation of 't' for 'tg_TJ'
  428. func (tg *tg_TJ) FmtTimeLong(t time.Time) string {
  429. b := make([]byte, 0, 32)
  430. if t.Hour() < 10 {
  431. b = append(b, '0')
  432. }
  433. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  434. b = append(b, tg.timeSeparator...)
  435. if t.Minute() < 10 {
  436. b = append(b, '0')
  437. }
  438. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  439. b = append(b, tg.timeSeparator...)
  440. if t.Second() < 10 {
  441. b = append(b, '0')
  442. }
  443. b = strconv.AppendInt(b, int64(t.Second()), 10)
  444. b = append(b, []byte{0x20}...)
  445. tz, _ := t.Zone()
  446. b = append(b, tz...)
  447. return string(b)
  448. }
  449. // FmtTimeFull returns the full time representation of 't' for 'tg_TJ'
  450. func (tg *tg_TJ) FmtTimeFull(t time.Time) string {
  451. b := make([]byte, 0, 32)
  452. if t.Hour() < 10 {
  453. b = append(b, '0')
  454. }
  455. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  456. b = append(b, tg.timeSeparator...)
  457. if t.Minute() < 10 {
  458. b = append(b, '0')
  459. }
  460. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  461. b = append(b, tg.timeSeparator...)
  462. if t.Second() < 10 {
  463. b = append(b, '0')
  464. }
  465. b = strconv.AppendInt(b, int64(t.Second()), 10)
  466. b = append(b, []byte{0x20}...)
  467. tz, _ := t.Zone()
  468. if btz, ok := tg.timezones[tz]; ok {
  469. b = append(b, btz...)
  470. } else {
  471. b = append(b, tz...)
  472. }
  473. return string(b)
  474. }