sbp_TZ.go 17 KB

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