1package qu_PE 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/gohugoio/locales" 9 "github.com/gohugoio/locales/currency" 10) 11 12type qu_PE 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 percentSuffix string 22 perMille string 23 timeSeparator string 24 inifinity string 25 currencies []string // idx = enum of currency code 26 currencyPositivePrefix string 27 currencyNegativePrefix string 28 monthsAbbreviated []string 29 monthsNarrow []string 30 monthsWide []string 31 daysAbbreviated []string 32 daysNarrow []string 33 daysShort []string 34 daysWide []string 35 periodsAbbreviated []string 36 periodsNarrow []string 37 periodsShort []string 38 periodsWide []string 39 erasAbbreviated []string 40 erasNarrow []string 41 erasWide []string 42 timezones map[string]string 43} 44 45// New returns a new instance of translator for the 'qu_PE' locale 46func New() locales.Translator { 47 return &qu_PE{ 48 locale: "qu_PE", 49 pluralsCardinal: nil, 50 pluralsOrdinal: nil, 51 pluralsRange: nil, 52 decimal: ".", 53 group: ",", 54 minus: "-", 55 percent: "%", 56 perMille: "‰", 57 timeSeparator: ":", 58 inifinity: "∞", 59 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"}, 60 percentSuffix: " ", 61 currencyPositivePrefix: " ", 62 currencyNegativePrefix: " ", 63 monthsAbbreviated: []string{"", "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Dic"}, 64 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, 65 monthsWide: []string{"", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre", "Noviembre", "Diciembre"}, 66 daysAbbreviated: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, 67 daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, 68 daysShort: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, 69 daysWide: []string{"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"}, 70 periodsAbbreviated: []string{"a.m.", "p.m."}, 71 periodsNarrow: []string{"a.m.", "p.m."}, 72 periodsWide: []string{"a.m.", "p.m."}, 73 erasAbbreviated: []string{"BCE", "d.C."}, 74 erasNarrow: []string{"", ""}, 75 erasWide: []string{"BCE", "d.C."}, 76 timezones: map[string]string{"ACDT": "Hora de Verano de Australia Central", "ACST": "Hora Estandar de Australia Central", "ACWDT": "Hora de Verano de Australia Central Occidental", "ACWST": "Hora Estandar de Australia Central Occidental", "ADT": "Hora De Verano del Atlántico", "AEDT": "Hora de Verano de Australia Oriental", "AEST": "Hora Estandar de Australia Oriental", "AKDT": "Hora de Verano de Alaska", "AKST": "Hora Estandar de Alaska", "ARST": "Hora de Verano de Argentina", "ART": "Hora Estandar de Argentina", "AST": "Hora Estandar del Atlántico", "AWDT": "Hora de Verano de Australia Occidental", "AWST": "Hora Estandar de Australia Occidental", "BOT": "Bolivia Time", "BT": "Hora de Bután", "CAT": "Hora de Africa Central", "CDT": "Hora Central de Verano", "CHADT": "Hora de Verano de Chatham", "CHAST": "Hora Estandar de Chatham", "CLST": "Hora de Verano de Chile", "CLT": "Hora Estandar de Chile", "COST": "Hora de Verano de Colombia", "COT": "Hora Estandar de Colombia", "CST": "Estandard Hora Central", "ChST": "Hora Estandar de Chamorro", "EAT": "Hora de Africa Oriental", "ECT": "Hora de Ecuador", "EDT": "Hora de Verano del Este", "EST": "Hora Estandar del Este", "GFT": "Hora de Guayana Francesa", "GMT": "Hora del Meridiano de Greenwich", "GST": "Hora Estandar del Golfo", "GYT": "Hora de Guyana", "HADT": "Hora de Verano de Hawai-Aleutiano", "HAST": "Hora Estandar de Hawai-Aleutiano", "HAT": "Hora de Verano de Terranova", "HECU": "Hora de Verano de Cuba", "HEEG": "Hora de Verano de Groenlandia", "HENOMX": "Hora de Verano del Noroeste de México", "HEOG": "Hora de Verano de Groenlandia Occidental", "HEPM": "Hora de Verano de San Pedro y Miquelón", "HEPMX": "Hora de Verano del Pacífico Mexicano", "HKST": "Hora de Verano de Hong Kong", "HKT": "Hora Estandar de Hong Kong", "HNCU": "Hora Estandar de Cuba", "HNEG": "Hora Estandar de Groenlandia", "HNNOMX": "Hora Estandar del Noroeste de México", "HNOG": "Hora Estandar de Groenlandia Occidental", "HNPM": "Hora Estandar de San Pedro y Miquelón", "HNPMX": "Hora Estandar del Pacífico Mexicano", "HNT": "Hora Estandar de Terranova", "IST": "Hora Estandar de India", "JDT": "Hora de Verano de Japón", "JST": "Hora Estandar de Japón", "LHDT": "Hora de Verano de Lord Howe", "LHST": "Hora Estandar de Lord Howe", "MDT": "Hora de Verano de la Montaña", "MESZ": "Hora de Verano de Europa Central", "MEZ": "Hora Estandar de Europa Central", "MST": "Hora Estandar de la Montaña", "MYT": "Hora de Malasia", "NZDT": "Hora de Verano de Nueva Zelanda", "NZST": "Hora Estandar de Nueva Zelanda", "OESZ": "Hora de Verano de Europa Oriental", "OEZ": "Hora Estandar de Europa Oriental", "PDT": "Hora de Verano del Pacífico", "PST": "Hora Estandar del Pacífico", "SAST": "Hora de Sudafrica", "SGT": "Hora Estandar de Singapur", "SRT": "Hora de Surinam", "TMST": "Hora de Verano de Turkmenistán", "TMT": "Hora Estandar de Turkmenistán", "UYST": "Hora de Verano de Uruguay", "UYT": "Hora Estandar de Uruguay", "VET": "Hora de Venezuela", "WARST": "Hora de Verano del Oeste de Argentina", "WART": "Hora Estandar del Oeste de Argentina", "WAST": "Hora Estandar de Verano de Africa Occidental", "WAT": "Hora Estandar de Africa Occidental", "WESZ": "Hora de Verano de Europa Occidental", "WEZ": "Hora Estandar de Europa Occidental", "WIB": "Hora de Indonesia Occidental", "WIT": "Hora de Indonesia Oriental", "WITA": "Hora de Indonesia Central", "∅∅∅": "Hora de Verano de Brasilia"}, 77 } 78} 79 80// Locale returns the current translators string locale 81func (qu *qu_PE) Locale() string { 82 return qu.locale 83} 84 85// PluralsCardinal returns the list of cardinal plural rules associated with 'qu_PE' 86func (qu *qu_PE) PluralsCardinal() []locales.PluralRule { 87 return qu.pluralsCardinal 88} 89 90// PluralsOrdinal returns the list of ordinal plural rules associated with 'qu_PE' 91func (qu *qu_PE) PluralsOrdinal() []locales.PluralRule { 92 return qu.pluralsOrdinal 93} 94 95// PluralsRange returns the list of range plural rules associated with 'qu_PE' 96func (qu *qu_PE) PluralsRange() []locales.PluralRule { 97 return qu.pluralsRange 98} 99 100// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'qu_PE' 101func (qu *qu_PE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 102 return locales.PluralRuleUnknown 103} 104 105// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'qu_PE' 106func (qu *qu_PE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 107 return locales.PluralRuleUnknown 108} 109 110// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'qu_PE' 111func (qu *qu_PE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 112 return locales.PluralRuleUnknown 113} 114 115// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 116func (qu *qu_PE) MonthAbbreviated(month time.Month) string { 117 return qu.monthsAbbreviated[month] 118} 119 120// MonthsAbbreviated returns the locales abbreviated months 121func (qu *qu_PE) MonthsAbbreviated() []string { 122 return qu.monthsAbbreviated[1:] 123} 124 125// MonthNarrow returns the locales narrow month given the 'month' provided 126func (qu *qu_PE) MonthNarrow(month time.Month) string { 127 return qu.monthsNarrow[month] 128} 129 130// MonthsNarrow returns the locales narrow months 131func (qu *qu_PE) MonthsNarrow() []string { 132 return qu.monthsNarrow[1:] 133} 134 135// MonthWide returns the locales wide month given the 'month' provided 136func (qu *qu_PE) MonthWide(month time.Month) string { 137 return qu.monthsWide[month] 138} 139 140// MonthsWide returns the locales wide months 141func (qu *qu_PE) MonthsWide() []string { 142 return qu.monthsWide[1:] 143} 144 145// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 146func (qu *qu_PE) WeekdayAbbreviated(weekday time.Weekday) string { 147 return qu.daysAbbreviated[weekday] 148} 149 150// WeekdaysAbbreviated returns the locales abbreviated weekdays 151func (qu *qu_PE) WeekdaysAbbreviated() []string { 152 return qu.daysAbbreviated 153} 154 155// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 156func (qu *qu_PE) WeekdayNarrow(weekday time.Weekday) string { 157 return qu.daysNarrow[weekday] 158} 159 160// WeekdaysNarrow returns the locales narrow weekdays 161func (qu *qu_PE) WeekdaysNarrow() []string { 162 return qu.daysNarrow 163} 164 165// WeekdayShort returns the locales short weekday given the 'weekday' provided 166func (qu *qu_PE) WeekdayShort(weekday time.Weekday) string { 167 return qu.daysShort[weekday] 168} 169 170// WeekdaysShort returns the locales short weekdays 171func (qu *qu_PE) WeekdaysShort() []string { 172 return qu.daysShort 173} 174 175// WeekdayWide returns the locales wide weekday given the 'weekday' provided 176func (qu *qu_PE) WeekdayWide(weekday time.Weekday) string { 177 return qu.daysWide[weekday] 178} 179 180// WeekdaysWide returns the locales wide weekdays 181func (qu *qu_PE) WeekdaysWide() []string { 182 return qu.daysWide 183} 184 185// Decimal returns the decimal point of number 186func (qu *qu_PE) Decimal() string { 187 return qu.decimal 188} 189 190// Group returns the group of number 191func (qu *qu_PE) Group() string { 192 return qu.group 193} 194 195// Group returns the minus sign of number 196func (qu *qu_PE) Minus() string { 197 return qu.minus 198} 199 200// FmtNumber returns 'num' with digits/precision of 'v' for 'qu_PE' and handles both Whole and Real numbers based on 'v' 201func (qu *qu_PE) FmtNumber(num float64, v uint64) string { 202 203 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 204 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 205 count := 0 206 inWhole := v == 0 207 b := make([]byte, 0, l) 208 209 for i := len(s) - 1; i >= 0; i-- { 210 211 if s[i] == '.' { 212 b = append(b, qu.decimal[0]) 213 inWhole = true 214 continue 215 } 216 217 if inWhole { 218 if count == 3 { 219 b = append(b, qu.group[0]) 220 count = 1 221 } else { 222 count++ 223 } 224 } 225 226 b = append(b, s[i]) 227 } 228 229 if num < 0 { 230 b = append(b, qu.minus[0]) 231 } 232 233 // reverse 234 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 235 b[i], b[j] = b[j], b[i] 236 } 237 238 return string(b) 239} 240 241// FmtPercent returns 'num' with digits/precision of 'v' for 'qu_PE' and handles both Whole and Real numbers based on 'v' 242// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 243func (qu *qu_PE) FmtPercent(num float64, v uint64) string { 244 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 245 l := len(s) + 5 246 b := make([]byte, 0, l) 247 248 for i := len(s) - 1; i >= 0; i-- { 249 250 if s[i] == '.' { 251 b = append(b, qu.decimal[0]) 252 continue 253 } 254 255 b = append(b, s[i]) 256 } 257 258 if num < 0 { 259 b = append(b, qu.minus[0]) 260 } 261 262 // reverse 263 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 264 b[i], b[j] = b[j], b[i] 265 } 266 267 b = append(b, qu.percentSuffix...) 268 269 b = append(b, qu.percent...) 270 271 return string(b) 272} 273 274// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'qu_PE' 275func (qu *qu_PE) FmtCurrency(num float64, v uint64, currency currency.Type) string { 276 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 284 for i := len(s) - 1; i >= 0; i-- { 285 286 if s[i] == '.' { 287 b = append(b, qu.decimal[0]) 288 inWhole = true 289 continue 290 } 291 292 if inWhole { 293 if count == 3 { 294 b = append(b, qu.group[0]) 295 count = 1 296 } else { 297 count++ 298 } 299 } 300 301 b = append(b, s[i]) 302 } 303 304 for j := len(symbol) - 1; j >= 0; j-- { 305 b = append(b, symbol[j]) 306 } 307 308 for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { 309 b = append(b, qu.currencyPositivePrefix[j]) 310 } 311 312 if num < 0 { 313 b = append(b, qu.minus[0]) 314 } 315 316 // reverse 317 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 318 b[i], b[j] = b[j], b[i] 319 } 320 321 if int(v) < 2 { 322 323 if v == 0 { 324 b = append(b, qu.decimal...) 325 } 326 327 for i := 0; i < 2-int(v); i++ { 328 b = append(b, '0') 329 } 330 } 331 332 return string(b) 333} 334 335// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'qu_PE' 336// in accounting notation. 337func (qu *qu_PE) FmtAccounting(num float64, v uint64, currency currency.Type) string { 338 339 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 340 symbol := qu.currencies[currency] 341 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 342 count := 0 343 inWhole := v == 0 344 b := make([]byte, 0, l) 345 346 for i := len(s) - 1; i >= 0; i-- { 347 348 if s[i] == '.' { 349 b = append(b, qu.decimal[0]) 350 inWhole = true 351 continue 352 } 353 354 if inWhole { 355 if count == 3 { 356 b = append(b, qu.group[0]) 357 count = 1 358 } else { 359 count++ 360 } 361 } 362 363 b = append(b, s[i]) 364 } 365 366 if num < 0 { 367 368 for j := len(symbol) - 1; j >= 0; j-- { 369 b = append(b, symbol[j]) 370 } 371 372 for j := len(qu.currencyNegativePrefix) - 1; j >= 0; j-- { 373 b = append(b, qu.currencyNegativePrefix[j]) 374 } 375 376 b = append(b, qu.minus[0]) 377 378 } else { 379 380 for j := len(symbol) - 1; j >= 0; j-- { 381 b = append(b, symbol[j]) 382 } 383 384 for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { 385 b = append(b, qu.currencyPositivePrefix[j]) 386 } 387 388 } 389 390 // reverse 391 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 392 b[i], b[j] = b[j], b[i] 393 } 394 395 if int(v) < 2 { 396 397 if v == 0 { 398 b = append(b, qu.decimal...) 399 } 400 401 for i := 0; i < 2-int(v); i++ { 402 b = append(b, '0') 403 } 404 } 405 406 return string(b) 407} 408 409// FmtDateShort returns the short date representation of 't' for 'qu_PE' 410func (qu *qu_PE) FmtDateShort(t time.Time) string { 411 412 b := make([]byte, 0, 32) 413 414 if t.Day() < 10 { 415 b = append(b, '0') 416 } 417 418 b = strconv.AppendInt(b, int64(t.Day()), 10) 419 b = append(b, []byte{0x2f}...) 420 421 if t.Month() < 10 { 422 b = append(b, '0') 423 } 424 425 b = strconv.AppendInt(b, int64(t.Month()), 10) 426 427 b = append(b, []byte{0x2f}...) 428 429 if t.Year() > 0 { 430 b = strconv.AppendInt(b, int64(t.Year()), 10) 431 } else { 432 b = strconv.AppendInt(b, int64(-t.Year()), 10) 433 } 434 435 return string(b) 436} 437 438// FmtDateMedium returns the medium date representation of 't' for 'qu_PE' 439func (qu *qu_PE) FmtDateMedium(t time.Time) string { 440 441 b := make([]byte, 0, 32) 442 443 b = strconv.AppendInt(b, int64(t.Day()), 10) 444 b = append(b, []byte{0x20}...) 445 b = append(b, qu.monthsAbbreviated[t.Month()]...) 446 b = append(b, []byte{0x20}...) 447 448 if t.Year() > 0 { 449 b = strconv.AppendInt(b, int64(t.Year()), 10) 450 } else { 451 b = strconv.AppendInt(b, int64(-t.Year()), 10) 452 } 453 454 return string(b) 455} 456 457// FmtDateLong returns the long date representation of 't' for 'qu_PE' 458func (qu *qu_PE) FmtDateLong(t time.Time) string { 459 460 b := make([]byte, 0, 32) 461 462 b = strconv.AppendInt(b, int64(t.Day()), 10) 463 b = append(b, []byte{0x20}...) 464 b = append(b, qu.monthsWide[t.Month()]...) 465 b = append(b, []byte{0x20}...) 466 467 if t.Year() > 0 { 468 b = strconv.AppendInt(b, int64(t.Year()), 10) 469 } else { 470 b = strconv.AppendInt(b, int64(-t.Year()), 10) 471 } 472 473 return string(b) 474} 475 476// FmtDateFull returns the full date representation of 't' for 'qu_PE' 477func (qu *qu_PE) FmtDateFull(t time.Time) string { 478 479 b := make([]byte, 0, 32) 480 481 b = append(b, qu.daysWide[t.Weekday()]...) 482 b = append(b, []byte{0x2c, 0x20}...) 483 b = strconv.AppendInt(b, int64(t.Day()), 10) 484 b = append(b, []byte{0x20}...) 485 b = append(b, qu.monthsWide[t.Month()]...) 486 b = append(b, []byte{0x2c, 0x20}...) 487 488 if t.Year() > 0 { 489 b = strconv.AppendInt(b, int64(t.Year()), 10) 490 } else { 491 b = strconv.AppendInt(b, int64(-t.Year()), 10) 492 } 493 494 return string(b) 495} 496 497// FmtTimeShort returns the short time representation of 't' for 'qu_PE' 498func (qu *qu_PE) FmtTimeShort(t time.Time) string { 499 500 b := make([]byte, 0, 32) 501 502 if t.Hour() < 10 { 503 b = append(b, '0') 504 } 505 506 b = strconv.AppendInt(b, int64(t.Hour()), 10) 507 b = append(b, qu.timeSeparator...) 508 509 if t.Minute() < 10 { 510 b = append(b, '0') 511 } 512 513 b = strconv.AppendInt(b, int64(t.Minute()), 10) 514 515 return string(b) 516} 517 518// FmtTimeMedium returns the medium time representation of 't' for 'qu_PE' 519func (qu *qu_PE) FmtTimeMedium(t time.Time) string { 520 521 b := make([]byte, 0, 32) 522 523 if t.Hour() < 10 { 524 b = append(b, '0') 525 } 526 527 b = strconv.AppendInt(b, int64(t.Hour()), 10) 528 b = append(b, qu.timeSeparator...) 529 530 if t.Minute() < 10 { 531 b = append(b, '0') 532 } 533 534 b = strconv.AppendInt(b, int64(t.Minute()), 10) 535 b = append(b, qu.timeSeparator...) 536 537 if t.Second() < 10 { 538 b = append(b, '0') 539 } 540 541 b = strconv.AppendInt(b, int64(t.Second()), 10) 542 543 return string(b) 544} 545 546// FmtTimeLong returns the long time representation of 't' for 'qu_PE' 547func (qu *qu_PE) FmtTimeLong(t time.Time) string { 548 549 b := make([]byte, 0, 32) 550 551 if t.Hour() < 10 { 552 b = append(b, '0') 553 } 554 555 b = strconv.AppendInt(b, int64(t.Hour()), 10) 556 b = append(b, qu.timeSeparator...) 557 558 if t.Minute() < 10 { 559 b = append(b, '0') 560 } 561 562 b = strconv.AppendInt(b, int64(t.Minute()), 10) 563 b = append(b, qu.timeSeparator...) 564 565 if t.Second() < 10 { 566 b = append(b, '0') 567 } 568 569 b = strconv.AppendInt(b, int64(t.Second()), 10) 570 b = append(b, []byte{0x20}...) 571 572 tz, _ := t.Zone() 573 b = append(b, tz...) 574 575 return string(b) 576} 577 578// FmtTimeFull returns the full time representation of 't' for 'qu_PE' 579func (qu *qu_PE) FmtTimeFull(t time.Time) string { 580 581 b := make([]byte, 0, 32) 582 583 if t.Hour() < 10 { 584 b = append(b, '0') 585 } 586 587 b = strconv.AppendInt(b, int64(t.Hour()), 10) 588 b = append(b, qu.timeSeparator...) 589 590 if t.Minute() < 10 { 591 b = append(b, '0') 592 } 593 594 b = strconv.AppendInt(b, int64(t.Minute()), 10) 595 b = append(b, qu.timeSeparator...) 596 597 if t.Second() < 10 { 598 b = append(b, '0') 599 } 600 601 b = strconv.AppendInt(b, int64(t.Second()), 10) 602 b = append(b, []byte{0x20}...) 603 604 tz, _ := t.Zone() 605 606 if btz, ok := qu.timezones[tz]; ok { 607 b = append(b, btz...) 608 } else { 609 b = append(b, tz...) 610 } 611 612 return string(b) 613} 614