qu_PE.go 18 KB

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