1package ps 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/gohugoio/locales" 9 "github.com/gohugoio/locales/currency" 10) 11 12type ps 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 perMille string 22 timeSeparator string 23 inifinity string 24 currencies []string // idx = enum of currency code 25 currencyPositiveSuffix string 26 currencyNegativeSuffix string 27 monthsAbbreviated []string 28 monthsNarrow []string 29 monthsWide []string 30 daysAbbreviated []string 31 daysNarrow []string 32 daysShort []string 33 daysWide []string 34 periodsAbbreviated []string 35 periodsNarrow []string 36 periodsShort []string 37 periodsWide []string 38 erasAbbreviated []string 39 erasNarrow []string 40 erasWide []string 41 timezones map[string]string 42} 43 44// New returns a new instance of translator for the 'ps' locale 45func New() locales.Translator { 46 return &ps{ 47 locale: "ps", 48 pluralsCardinal: []locales.PluralRule{2, 6}, 49 pluralsOrdinal: []locales.PluralRule{6}, 50 pluralsRange: []locales.PluralRule{2, 6}, 51 percent: "٪", 52 perMille: "؉", 53 timeSeparator: ":", 54 inifinity: "∞", 55 currencies: []string{"ADP", "AED", "AFA", "؋", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "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", "р.", "BYR", "BZD", "CA$", "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", "C$", "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", "$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "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 currencyPositiveSuffix: " ", 57 currencyNegativeSuffix: " ", 58 monthsAbbreviated: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سېپتمبر", "اکتوبر", "نومبر", "دسمبر"}, 59 monthsNarrow: []string{"", "ج", "ف", "م", "ا", "م", "ج", "ج", "ا", "س", "ا", "ن", "د"}, 60 monthsWide: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سېپتمبر", "اکتوبر", "نومبر", "دسمبر"}, 61 daysAbbreviated: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"}, 62 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, 63 daysShort: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"}, 64 daysWide: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"}, 65 periodsAbbreviated: []string{"غ.م.", "غ.و."}, 66 periodsNarrow: []string{"غ.م.", "غ.و."}, 67 periodsWide: []string{"غ.م.", "غ.و."}, 68 erasAbbreviated: []string{"له میلاد وړاندې", "م."}, 69 erasNarrow: []string{"", ""}, 70 erasWide: []string{"له میلاد څخه وړاندې", "له میلاد څخه وروسته"}, 71 timezones: map[string]string{"ACDT": "آسترالوي مرکزي د ورځې روښانه وخت", "ACST": "آسترالوي مرکزي معياري وخت", "ACWDT": "آسترالوي مرکزي لوېديځ د ورځې روښانه وخت", "ACWST": "آسترالوي مرکزي لوېديځ معياري وخت", "ADT": "اتلانتیک د رڼا ورځې وخت", "AEDT": "آسترالوي ختيځ د ورځې روښانه وخت", "AEST": "آسترالوي ختيځ معياري وخت", "AKDT": "الاسکا د ورځې روښانه وخت", "AKST": "الاسکا معياري وخت", "ARST": "ارجنټاین اوړي وخت", "ART": "ارجنټاین معیاری وخت", "AST": "اتلانتیک معياري وخت", "AWDT": "آسترالوي لوېديځ د ورځې روښانه وخت", "AWST": "آسترالوي لوېديځ معياري وخت", "BOT": "بولیویا وخت", "BT": "بهوټان وخت", "CAT": "منځنی افريقا وخت", "CDT": "مرکزي د ورځې روښانه وخت", "CHADT": "چاتام د ورځې روښانه وخت", "CHAST": "چاتام معياري وخت", "CLST": "چلی اوړي وخت", "CLT": "چلی معیاری وخت", "COST": "کولمبیا اوړي وخت", "COT": "کولمبیا معیاری وخت", "CST": "مرکزي معياري وخت", "ChST": "چمارو معياري وخت", "EAT": "ختيځ افريقا وخت", "ECT": "د اکوادور وخت", "EDT": "ختيځ د رڼا ورځې وخت", "EST": "ختيځ معياري وخت", "GFT": "د فرانسوي ګانا وخت", "GMT": "ګرينويچ معياري وخت", "GST": "خلیج معياري وخت", "GYT": "د ګوانانا وخت", "HADT": "هوایی الیوتین رڼا ورځې وخت", "HAST": "هوایی الیوتین معیاری وخت", "HAT": "نيو فاونډلېنډ د ورځې روښانه وخت", "HECU": "کیوبا د رڼا ورځې وخت", "HEEG": "د ختیځ ګرینلینډ اوړي وخت", "HENOMX": "د شمال لویدیځ مکسیکو رڼا ورځې وخت", "HEOG": "لویدیځ ګرینلینډ اوړي وخت", "HEPM": "سینټ پییرا و ميکلين رڼا ورځې وخت", "HEPMX": "مکسیکن پیسفک رڼا ورځې وخت", "HKST": "هانګ کانګ اوړي وخت", "HKT": "هانګ کانګ معياري وخت", "HNCU": "کیوبا معياري وخت", "HNEG": "د ختیځ ګرینلینډ معياري وخت", "HNNOMX": "د شمال لویدیځ مکسیکو معیاري وخت", "HNOG": "لویدیځ ګرینلینډ معياري وخت", "HNPM": "سینټ پییرا و ميکلين معیاری وخت", "HNPMX": "مکسیکن پیسفک معیاری وخت", "HNT": "د نوي فیلډلینډ معیاری وخت", "IST": "هند معیاري وخت", "JDT": "جاپان د ورځې روښانه وخت", "JST": "جاپان معياري وخت", "LHDT": "لارډ هوي د ورځې روښانه وخت", "LHST": "لارډ هوي معياري وخت", "MDT": "د غره د رڼا ورځې وخت", "MESZ": "وسطي اروپايي د اوړي وخت", "MEZ": "د مرکزي اروپا معیاري وخت", "MST": "د غره معياري وخت", "MYT": "ملائیشیا وخت", "NZDT": "نيوزي لېنډ د ورځې روښانه وخت", "NZST": "نيوزي لېنډ معياري وخت", "OESZ": "ختيځ اروپايي اوړي وخت", "OEZ": "ختيځ اروپايي معياري وخت", "PDT": "پیسفک د رڼا ورځې وخت", "PST": "د پیسفک معياري وخت", "SAST": "جنوبي افريقا معياري وخت", "SGT": "سنګاپور معیاري وخت", "SRT": "سورینام وخت", "TMST": "ترکمنستان اوړي وخت", "TMT": "ترکمنستان معياري وخت", "UYST": "یوروګوای اوړي وخت", "UYT": "یوروګوای معياري وخت", "VET": "وینزویلا وخت", "WARST": "لوېديځ ارجنټاين اوړي وخت", "WART": "لوېديځ ارجنټاين معياري وخت", "WAST": "د افریقا افریقا لویدیځ وخت", "WAT": "لویدیځ افریقایي معیاري وخت", "WESZ": "لوېديځ اروپايي اوړي وخت", "WEZ": "لوېديځ اروپايي معياري وخت", "WIB": "لویدیځ اندونیزیا وخت", "WIT": "اندونیزیا وخت", "WITA": "مرکزي ادونيزيا وخت", "∅∅∅": "ايزورس اوړي وخت"}, 72 } 73} 74 75// Locale returns the current translators string locale 76func (ps *ps) Locale() string { 77 return ps.locale 78} 79 80// PluralsCardinal returns the list of cardinal plural rules associated with 'ps' 81func (ps *ps) PluralsCardinal() []locales.PluralRule { 82 return ps.pluralsCardinal 83} 84 85// PluralsOrdinal returns the list of ordinal plural rules associated with 'ps' 86func (ps *ps) PluralsOrdinal() []locales.PluralRule { 87 return ps.pluralsOrdinal 88} 89 90// PluralsRange returns the list of range plural rules associated with 'ps' 91func (ps *ps) PluralsRange() []locales.PluralRule { 92 return ps.pluralsRange 93} 94 95// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ps' 96func (ps *ps) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 97 98 n := math.Abs(num) 99 100 if n == 1 { 101 return locales.PluralRuleOne 102 } 103 104 return locales.PluralRuleOther 105} 106 107// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ps' 108func (ps *ps) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 109 return locales.PluralRuleOther 110} 111 112// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ps' 113func (ps *ps) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 114 115 start := ps.CardinalPluralRule(num1, v1) 116 end := ps.CardinalPluralRule(num2, v2) 117 118 if start == locales.PluralRuleOne && end == locales.PluralRuleOne { 119 return locales.PluralRuleOne 120 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { 121 return locales.PluralRuleOther 122 } 123 124 return locales.PluralRuleOther 125 126} 127 128// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 129func (ps *ps) MonthAbbreviated(month time.Month) string { 130 return ps.monthsAbbreviated[month] 131} 132 133// MonthsAbbreviated returns the locales abbreviated months 134func (ps *ps) MonthsAbbreviated() []string { 135 return ps.monthsAbbreviated[1:] 136} 137 138// MonthNarrow returns the locales narrow month given the 'month' provided 139func (ps *ps) MonthNarrow(month time.Month) string { 140 return ps.monthsNarrow[month] 141} 142 143// MonthsNarrow returns the locales narrow months 144func (ps *ps) MonthsNarrow() []string { 145 return ps.monthsNarrow[1:] 146} 147 148// MonthWide returns the locales wide month given the 'month' provided 149func (ps *ps) MonthWide(month time.Month) string { 150 return ps.monthsWide[month] 151} 152 153// MonthsWide returns the locales wide months 154func (ps *ps) MonthsWide() []string { 155 return ps.monthsWide[1:] 156} 157 158// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 159func (ps *ps) WeekdayAbbreviated(weekday time.Weekday) string { 160 return ps.daysAbbreviated[weekday] 161} 162 163// WeekdaysAbbreviated returns the locales abbreviated weekdays 164func (ps *ps) WeekdaysAbbreviated() []string { 165 return ps.daysAbbreviated 166} 167 168// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 169func (ps *ps) WeekdayNarrow(weekday time.Weekday) string { 170 return ps.daysNarrow[weekday] 171} 172 173// WeekdaysNarrow returns the locales narrow weekdays 174func (ps *ps) WeekdaysNarrow() []string { 175 return ps.daysNarrow 176} 177 178// WeekdayShort returns the locales short weekday given the 'weekday' provided 179func (ps *ps) WeekdayShort(weekday time.Weekday) string { 180 return ps.daysShort[weekday] 181} 182 183// WeekdaysShort returns the locales short weekdays 184func (ps *ps) WeekdaysShort() []string { 185 return ps.daysShort 186} 187 188// WeekdayWide returns the locales wide weekday given the 'weekday' provided 189func (ps *ps) WeekdayWide(weekday time.Weekday) string { 190 return ps.daysWide[weekday] 191} 192 193// WeekdaysWide returns the locales wide weekdays 194func (ps *ps) WeekdaysWide() []string { 195 return ps.daysWide 196} 197 198// Decimal returns the decimal point of number 199func (ps *ps) Decimal() string { 200 return ps.decimal 201} 202 203// Group returns the group of number 204func (ps *ps) Group() string { 205 return ps.group 206} 207 208// Group returns the minus sign of number 209func (ps *ps) Minus() string { 210 return ps.minus 211} 212 213// FmtNumber returns 'num' with digits/precision of 'v' for 'ps' and handles both Whole and Real numbers based on 'v' 214func (ps *ps) FmtNumber(num float64, v uint64) string { 215 216 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 217} 218 219// FmtPercent returns 'num' with digits/precision of 'v' for 'ps' and handles both Whole and Real numbers based on 'v' 220// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 221func (ps *ps) FmtPercent(num float64, v uint64) string { 222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 223 l := len(s) + 2 224 b := make([]byte, 0, l) 225 226 for i := len(s) - 1; i >= 0; i-- { 227 228 if s[i] == '.' { 229 b = append(b, ps.decimal[0]) 230 continue 231 } 232 233 b = append(b, s[i]) 234 } 235 236 if num < 0 { 237 b = append(b, ps.minus[0]) 238 } 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 245 b = append(b, ps.percent...) 246 247 return string(b) 248} 249 250// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ps' 251func (ps *ps) FmtCurrency(num float64, v uint64, currency currency.Type) string { 252 253 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 254 symbol := ps.currencies[currency] 255 l := len(s) + len(symbol) + 2 256 count := 0 257 inWhole := v == 0 258 b := make([]byte, 0, l) 259 260 for i := len(s) - 1; i >= 0; i-- { 261 262 if s[i] == '.' { 263 b = append(b, ps.decimal[0]) 264 inWhole = true 265 continue 266 } 267 268 if inWhole { 269 if count == 3 { 270 b = append(b, ps.group[0]) 271 count = 1 272 } else { 273 count++ 274 } 275 } 276 277 b = append(b, s[i]) 278 } 279 280 if num < 0 { 281 b = append(b, ps.minus[0]) 282 } 283 284 // reverse 285 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 286 b[i], b[j] = b[j], b[i] 287 } 288 289 if int(v) < 2 { 290 291 if v == 0 { 292 b = append(b, ps.decimal...) 293 } 294 295 for i := 0; i < 2-int(v); i++ { 296 b = append(b, '0') 297 } 298 } 299 300 b = append(b, ps.currencyPositiveSuffix...) 301 302 b = append(b, symbol...) 303 304 return string(b) 305} 306 307// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ps' 308// in accounting notation. 309func (ps *ps) FmtAccounting(num float64, v uint64, currency currency.Type) string { 310 311 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 312 symbol := ps.currencies[currency] 313 l := len(s) + len(symbol) + 2 314 count := 0 315 inWhole := v == 0 316 b := make([]byte, 0, l) 317 318 for i := len(s) - 1; i >= 0; i-- { 319 320 if s[i] == '.' { 321 b = append(b, ps.decimal[0]) 322 inWhole = true 323 continue 324 } 325 326 if inWhole { 327 if count == 3 { 328 b = append(b, ps.group[0]) 329 count = 1 330 } else { 331 count++ 332 } 333 } 334 335 b = append(b, s[i]) 336 } 337 338 if num < 0 { 339 340 b = append(b, ps.minus[0]) 341 342 } 343 344 // reverse 345 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 346 b[i], b[j] = b[j], b[i] 347 } 348 349 if int(v) < 2 { 350 351 if v == 0 { 352 b = append(b, ps.decimal...) 353 } 354 355 for i := 0; i < 2-int(v); i++ { 356 b = append(b, '0') 357 } 358 } 359 360 if num < 0 { 361 b = append(b, ps.currencyNegativeSuffix...) 362 b = append(b, symbol...) 363 } else { 364 365 b = append(b, ps.currencyPositiveSuffix...) 366 b = append(b, symbol...) 367 } 368 369 return string(b) 370} 371 372// FmtDateShort returns the short date representation of 't' for 'ps' 373func (ps *ps) FmtDateShort(t time.Time) string { 374 375 b := make([]byte, 0, 32) 376 377 if t.Year() > 0 { 378 b = strconv.AppendInt(b, int64(t.Year()), 10) 379 } else { 380 b = strconv.AppendInt(b, int64(-t.Year()), 10) 381 } 382 383 b = append(b, []byte{0x2f}...) 384 b = strconv.AppendInt(b, int64(t.Month()), 10) 385 b = append(b, []byte{0x2f}...) 386 b = strconv.AppendInt(b, int64(t.Day()), 10) 387 388 return string(b) 389} 390 391// FmtDateMedium returns the medium date representation of 't' for 'ps' 392func (ps *ps) FmtDateMedium(t time.Time) string { 393 394 b := make([]byte, 0, 32) 395 396 if t.Year() > 0 { 397 b = strconv.AppendInt(b, int64(t.Year()), 10) 398 } else { 399 b = strconv.AppendInt(b, int64(-t.Year()), 10) 400 } 401 402 b = append(b, []byte{0x20}...) 403 b = append(b, ps.monthsAbbreviated[t.Month()]...) 404 b = append(b, []byte{0x20}...) 405 b = strconv.AppendInt(b, int64(t.Day()), 10) 406 407 return string(b) 408} 409 410// FmtDateLong returns the long date representation of 't' for 'ps' 411func (ps *ps) FmtDateLong(t time.Time) string { 412 413 b := make([]byte, 0, 32) 414 415 b = append(b, []byte{0xd8, 0xaf, 0x20}...) 416 417 if t.Year() > 0 { 418 b = strconv.AppendInt(b, int64(t.Year()), 10) 419 } else { 420 b = strconv.AppendInt(b, int64(-t.Year()), 10) 421 } 422 423 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) 424 b = append(b, ps.monthsWide[t.Month()]...) 425 b = append(b, []byte{0x20}...) 426 b = strconv.AppendInt(b, int64(t.Day()), 10) 427 428 return string(b) 429} 430 431// FmtDateFull returns the full date representation of 't' for 'ps' 432func (ps *ps) FmtDateFull(t time.Time) string { 433 434 b := make([]byte, 0, 32) 435 436 b = append(b, ps.daysWide[t.Weekday()]...) 437 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) 438 439 if t.Year() > 0 { 440 b = strconv.AppendInt(b, int64(t.Year()), 10) 441 } else { 442 b = strconv.AppendInt(b, int64(-t.Year()), 10) 443 } 444 445 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) 446 b = append(b, ps.monthsWide[t.Month()]...) 447 b = append(b, []byte{0x20}...) 448 b = strconv.AppendInt(b, int64(t.Day()), 10) 449 450 return string(b) 451} 452 453// FmtTimeShort returns the short time representation of 't' for 'ps' 454func (ps *ps) FmtTimeShort(t time.Time) string { 455 456 b := make([]byte, 0, 32) 457 458 b = strconv.AppendInt(b, int64(t.Hour()), 10) 459 b = append(b, ps.timeSeparator...) 460 461 if t.Minute() < 10 { 462 b = append(b, '0') 463 } 464 465 b = strconv.AppendInt(b, int64(t.Minute()), 10) 466 467 return string(b) 468} 469 470// FmtTimeMedium returns the medium time representation of 't' for 'ps' 471func (ps *ps) FmtTimeMedium(t time.Time) string { 472 473 b := make([]byte, 0, 32) 474 475 b = strconv.AppendInt(b, int64(t.Hour()), 10) 476 b = append(b, ps.timeSeparator...) 477 478 if t.Minute() < 10 { 479 b = append(b, '0') 480 } 481 482 b = strconv.AppendInt(b, int64(t.Minute()), 10) 483 b = append(b, ps.timeSeparator...) 484 485 if t.Second() < 10 { 486 b = append(b, '0') 487 } 488 489 b = strconv.AppendInt(b, int64(t.Second()), 10) 490 491 return string(b) 492} 493 494// FmtTimeLong returns the long time representation of 't' for 'ps' 495func (ps *ps) FmtTimeLong(t time.Time) string { 496 497 b := make([]byte, 0, 32) 498 499 b = strconv.AppendInt(b, int64(t.Hour()), 10) 500 b = append(b, ps.timeSeparator...) 501 502 if t.Minute() < 10 { 503 b = append(b, '0') 504 } 505 506 b = strconv.AppendInt(b, int64(t.Minute()), 10) 507 b = append(b, ps.timeSeparator...) 508 509 if t.Second() < 10 { 510 b = append(b, '0') 511 } 512 513 b = strconv.AppendInt(b, int64(t.Second()), 10) 514 b = append(b, []byte{0x20, 0x28}...) 515 516 tz, _ := t.Zone() 517 b = append(b, tz...) 518 519 b = append(b, []byte{0x29}...) 520 521 return string(b) 522} 523 524// FmtTimeFull returns the full time representation of 't' for 'ps' 525func (ps *ps) FmtTimeFull(t time.Time) string { 526 527 b := make([]byte, 0, 32) 528 529 b = strconv.AppendInt(b, int64(t.Hour()), 10) 530 b = append(b, ps.timeSeparator...) 531 532 if t.Minute() < 10 { 533 b = append(b, '0') 534 } 535 536 b = strconv.AppendInt(b, int64(t.Minute()), 10) 537 b = append(b, ps.timeSeparator...) 538 539 if t.Second() < 10 { 540 b = append(b, '0') 541 } 542 543 b = strconv.AppendInt(b, int64(t.Second()), 10) 544 b = append(b, []byte{0x20, 0x28}...) 545 546 tz, _ := t.Zone() 547 548 if btz, ok := ps.timezones[tz]; ok { 549 b = append(b, btz...) 550 } else { 551 b = append(b, tz...) 552 } 553 554 b = append(b, []byte{0x29}...) 555 556 return string(b) 557} 558