1package id 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/go-playground/locales" 9 "github.com/go-playground/locales/currency" 10) 11 12type id 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 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 42// New returns a new instance of translator for the 'id' locale 43func New() locales.Translator { 44 return &id{ 45 locale: "id", 46 pluralsCardinal: []locales.PluralRule{6}, 47 pluralsOrdinal: []locales.PluralRule{6}, 48 pluralsRange: []locales.PluralRule{6}, 49 decimal: ",", 50 group: ".", 51 minus: "-", 52 percent: "%", 53 perMille: "‰", 54 timeSeparator: ".", 55 inifinity: "∞", 56 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "Rp", "IEP", "ILP", "ILR", "₪", "Rs", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "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", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, 57 monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"}, 58 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, 59 monthsWide: []string{"", "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"}, 60 daysAbbreviated: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, 61 daysNarrow: []string{"M", "S", "S", "R", "K", "J", "S"}, 62 daysShort: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, 63 daysWide: []string{"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"}, 64 periodsAbbreviated: []string{"AM", "PM"}, 65 periodsNarrow: []string{"AM", "PM"}, 66 periodsWide: []string{"AM", "PM"}, 67 erasAbbreviated: []string{"SM", "M"}, 68 erasNarrow: []string{"SM", "M"}, 69 erasWide: []string{"Sebelum Masehi", "Masehi"}, 70 timezones: map[string]string{"CLT": "Waktu Standar Cile", "HAST": "Waktu Standar Hawaii-Aleutian", "PDT": "Waktu Musim Panas Pasifik", "BOT": "Waktu Bolivia", "BT": "Waktu Bhutan", "SGT": "Waktu Standar Singapura", "EDT": "Waktu Musim Panas Timur", "HKST": "Waktu Musim Panas Hong Kong", "ACWDT": "Waktu Musim Panas Barat Tengah Australia", "SRT": "Waktu Suriname", "HNCU": "Waktu Standar Kuba", "CAT": "Waktu Afrika Tengah", "EAT": "Waktu Afrika Timur", "AWST": "Waktu Standar Barat Australia", "HNOG": "Waktu Standar Greenland Barat", "MESZ": "Waktu Musim Panas Eropa Tengah", "WART": "Waktu Standar Argentina Bagian Barat", "LHST": "Waktu Standar Lord Howe", "WIT": "Waktu Indonesia Timur", "WIB": "Waktu Indonesia Barat", "SAST": "Waktu Standar Afrika Selatan", "GFT": "Waktu Guyana Prancis", "IST": "Waktu India", "AWDT": "Waktu Musim Panas Barat Australia", "CDT": "Waktu Musim Panas Tengah", "ADT": "Waktu Musim Panas Atlantik", "WESZ": "Waktu Musim Panas Eropa Barat", "ECT": "Waktu Ekuador", "HEEG": "Waktu Musim Panas Greenland Timur", "COT": "Waktu Standar Kolombia", "HEPMX": "Waktu Musim Panas Pasifik Meksiko", "AEDT": "Waktu Musim Panas Timur Australia", "AST": "Waktu Standar Atlantik", "AKDT": "Waktu Musim Panas Alaska", "EST": "Waktu Standar Timur", "HAT": "Waktu Musim Panas Newfoundland", "HENOMX": "Waktu Musim Panas Meksiko Barat Laut", "COST": "Waktu Musim Panas Kolombia", "WARST": "Waktu Musim Panas Argentina Bagian Barat", "HNPM": "Waktu Standar Saint Pierre dan Miquelon", "MST": "Waktu Standar Makau", "UYT": "Waktu Standar Uruguay", "WAT": "Waktu Standar Afrika Barat", "TMST": "Waktu Musim Panas Turkmenistan", "HNPMX": "Waktu Standar Pasifik Meksiko", "WEZ": "Waktu Standar Eropa Barat", "NZST": "Waktu Standar Selandia Baru", "ACWST": "Waktu Standar Barat Tengah Australia", "OESZ": "Waktu Musim Panas Eropa Timur", "HADT": "Waktu Musim Panas Hawaii-Aleutian", "CHAST": "Waktu Standar Chatham", "HEPM": "Waktu Musim Panas Saint Pierre dan Miquelon", "TMT": "Waktu Standar Turkmenistan", "ART": "Waktu Standar Argentina", "ARST": "Waktu Musim Panas Argentina", "HECU": "Waktu Musim Panas Kuba", "MYT": "Waktu Malaysia", "JST": "Waktu Standar Jepang", "NZDT": "Waktu Musim Panas Selandia Baru", "ACDT": "Waktu Musim Panas Tengah Australia", "∅∅∅": "Waktu Musim Panas Azores", "AEST": "Waktu Standar Timur Australia", "JDT": "Waktu Musim Panas Jepang", "HNEG": "Waktu Standar Greenland Timur", "ACST": "Waktu Standar Tengah Australia", "UYST": "Waktu Musim Panas Uruguay", "GMT": "Greenwich Mean Time", "WITA": "Waktu Indonesia Tengah", "CLST": "Waktu Musim Panas Cile", "PST": "Waktu Standar Pasifik", "WAST": "Waktu Musim Panas Afrika Barat", "AKST": "Waktu Standar Alaska", "MEZ": "Waktu Standar Eropa Tengah", "HKT": "Waktu Standar Hong Kong", "LHDT": "Waktu Musim Panas Lord Howe", "VET": "Waktu Venezuela", "CHADT": "Waktu Musim Panas Chatham", "CST": "Waktu Standar Tengah", "HEOG": "Waktu Musim Panas Greenland Barat", "HNNOMX": "Waktu Standar Meksiko Barat Laut", "MDT": "Waktu Musim Panas Makau", "GYT": "Waktu Guyana", "ChST": "Waktu Standar Chamorro", "HNT": "Waktu Standar Newfoundland", "OEZ": "Waktu Standar Eropa Timur"}, 71 } 72} 73 74// Locale returns the current translators string locale 75func (id *id) Locale() string { 76 return id.locale 77} 78 79// PluralsCardinal returns the list of cardinal plural rules associated with 'id' 80func (id *id) PluralsCardinal() []locales.PluralRule { 81 return id.pluralsCardinal 82} 83 84// PluralsOrdinal returns the list of ordinal plural rules associated with 'id' 85func (id *id) PluralsOrdinal() []locales.PluralRule { 86 return id.pluralsOrdinal 87} 88 89// PluralsRange returns the list of range plural rules associated with 'id' 90func (id *id) PluralsRange() []locales.PluralRule { 91 return id.pluralsRange 92} 93 94// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'id' 95func (id *id) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 96 return locales.PluralRuleOther 97} 98 99// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'id' 100func (id *id) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 101 return locales.PluralRuleOther 102} 103 104// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'id' 105func (id *id) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 106 return locales.PluralRuleOther 107} 108 109// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 110func (id *id) MonthAbbreviated(month time.Month) string { 111 return id.monthsAbbreviated[month] 112} 113 114// MonthsAbbreviated returns the locales abbreviated months 115func (id *id) MonthsAbbreviated() []string { 116 return id.monthsAbbreviated[1:] 117} 118 119// MonthNarrow returns the locales narrow month given the 'month' provided 120func (id *id) MonthNarrow(month time.Month) string { 121 return id.monthsNarrow[month] 122} 123 124// MonthsNarrow returns the locales narrow months 125func (id *id) MonthsNarrow() []string { 126 return id.monthsNarrow[1:] 127} 128 129// MonthWide returns the locales wide month given the 'month' provided 130func (id *id) MonthWide(month time.Month) string { 131 return id.monthsWide[month] 132} 133 134// MonthsWide returns the locales wide months 135func (id *id) MonthsWide() []string { 136 return id.monthsWide[1:] 137} 138 139// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 140func (id *id) WeekdayAbbreviated(weekday time.Weekday) string { 141 return id.daysAbbreviated[weekday] 142} 143 144// WeekdaysAbbreviated returns the locales abbreviated weekdays 145func (id *id) WeekdaysAbbreviated() []string { 146 return id.daysAbbreviated 147} 148 149// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 150func (id *id) WeekdayNarrow(weekday time.Weekday) string { 151 return id.daysNarrow[weekday] 152} 153 154// WeekdaysNarrow returns the locales narrow weekdays 155func (id *id) WeekdaysNarrow() []string { 156 return id.daysNarrow 157} 158 159// WeekdayShort returns the locales short weekday given the 'weekday' provided 160func (id *id) WeekdayShort(weekday time.Weekday) string { 161 return id.daysShort[weekday] 162} 163 164// WeekdaysShort returns the locales short weekdays 165func (id *id) WeekdaysShort() []string { 166 return id.daysShort 167} 168 169// WeekdayWide returns the locales wide weekday given the 'weekday' provided 170func (id *id) WeekdayWide(weekday time.Weekday) string { 171 return id.daysWide[weekday] 172} 173 174// WeekdaysWide returns the locales wide weekdays 175func (id *id) WeekdaysWide() []string { 176 return id.daysWide 177} 178 179// Decimal returns the decimal point of number 180func (id *id) Decimal() string { 181 return id.decimal 182} 183 184// Group returns the group of number 185func (id *id) Group() string { 186 return id.group 187} 188 189// Group returns the minus sign of number 190func (id *id) Minus() string { 191 return id.minus 192} 193 194// FmtNumber returns 'num' with digits/precision of 'v' for 'id' and handles both Whole and Real numbers based on 'v' 195func (id *id) FmtNumber(num float64, v uint64) string { 196 197 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 198 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 199 count := 0 200 inWhole := v == 0 201 b := make([]byte, 0, l) 202 203 for i := len(s) - 1; i >= 0; i-- { 204 205 if s[i] == '.' { 206 b = append(b, id.decimal[0]) 207 inWhole = true 208 continue 209 } 210 211 if inWhole { 212 if count == 3 { 213 b = append(b, id.group[0]) 214 count = 1 215 } else { 216 count++ 217 } 218 } 219 220 b = append(b, s[i]) 221 } 222 223 if num < 0 { 224 b = append(b, id.minus[0]) 225 } 226 227 // reverse 228 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 229 b[i], b[j] = b[j], b[i] 230 } 231 232 return string(b) 233} 234 235// FmtPercent returns 'num' with digits/precision of 'v' for 'id' and handles both Whole and Real numbers based on 'v' 236// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 237func (id *id) FmtPercent(num float64, v uint64) string { 238 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 239 l := len(s) + 3 240 b := make([]byte, 0, l) 241 242 for i := len(s) - 1; i >= 0; i-- { 243 244 if s[i] == '.' { 245 b = append(b, id.decimal[0]) 246 continue 247 } 248 249 b = append(b, s[i]) 250 } 251 252 if num < 0 { 253 b = append(b, id.minus[0]) 254 } 255 256 // reverse 257 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 258 b[i], b[j] = b[j], b[i] 259 } 260 261 b = append(b, id.percent...) 262 263 return string(b) 264} 265 266// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'id' 267func (id *id) FmtCurrency(num float64, v uint64, currency currency.Type) string { 268 269 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 270 symbol := id.currencies[currency] 271 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 272 count := 0 273 inWhole := v == 0 274 b := make([]byte, 0, l) 275 276 for i := len(s) - 1; i >= 0; i-- { 277 278 if s[i] == '.' { 279 b = append(b, id.decimal[0]) 280 inWhole = true 281 continue 282 } 283 284 if inWhole { 285 if count == 3 { 286 b = append(b, id.group[0]) 287 count = 1 288 } else { 289 count++ 290 } 291 } 292 293 b = append(b, s[i]) 294 } 295 296 for j := len(symbol) - 1; j >= 0; j-- { 297 b = append(b, symbol[j]) 298 } 299 300 if num < 0 { 301 b = append(b, id.minus[0]) 302 } 303 304 // reverse 305 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 306 b[i], b[j] = b[j], b[i] 307 } 308 309 if int(v) < 2 { 310 311 if v == 0 { 312 b = append(b, id.decimal...) 313 } 314 315 for i := 0; i < 2-int(v); i++ { 316 b = append(b, '0') 317 } 318 } 319 320 return string(b) 321} 322 323// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'id' 324// in accounting notation. 325func (id *id) FmtAccounting(num float64, v uint64, currency currency.Type) string { 326 327 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 328 symbol := id.currencies[currency] 329 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 330 count := 0 331 inWhole := v == 0 332 b := make([]byte, 0, l) 333 334 for i := len(s) - 1; i >= 0; i-- { 335 336 if s[i] == '.' { 337 b = append(b, id.decimal[0]) 338 inWhole = true 339 continue 340 } 341 342 if inWhole { 343 if count == 3 { 344 b = append(b, id.group[0]) 345 count = 1 346 } else { 347 count++ 348 } 349 } 350 351 b = append(b, s[i]) 352 } 353 354 if num < 0 { 355 356 for j := len(symbol) - 1; j >= 0; j-- { 357 b = append(b, symbol[j]) 358 } 359 360 b = append(b, id.minus[0]) 361 362 } else { 363 364 for j := len(symbol) - 1; j >= 0; j-- { 365 b = append(b, symbol[j]) 366 } 367 368 } 369 370 // reverse 371 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 372 b[i], b[j] = b[j], b[i] 373 } 374 375 if int(v) < 2 { 376 377 if v == 0 { 378 b = append(b, id.decimal...) 379 } 380 381 for i := 0; i < 2-int(v); i++ { 382 b = append(b, '0') 383 } 384 } 385 386 return string(b) 387} 388 389// FmtDateShort returns the short date representation of 't' for 'id' 390func (id *id) FmtDateShort(t time.Time) string { 391 392 b := make([]byte, 0, 32) 393 394 if t.Day() < 10 { 395 b = append(b, '0') 396 } 397 398 b = strconv.AppendInt(b, int64(t.Day()), 10) 399 b = append(b, []byte{0x2f}...) 400 401 if t.Month() < 10 { 402 b = append(b, '0') 403 } 404 405 b = strconv.AppendInt(b, int64(t.Month()), 10) 406 407 b = append(b, []byte{0x2f}...) 408 409 if t.Year() > 9 { 410 b = append(b, strconv.Itoa(t.Year())[2:]...) 411 } else { 412 b = append(b, strconv.Itoa(t.Year())[1:]...) 413 } 414 415 return string(b) 416} 417 418// FmtDateMedium returns the medium date representation of 't' for 'id' 419func (id *id) FmtDateMedium(t time.Time) string { 420 421 b := make([]byte, 0, 32) 422 423 b = strconv.AppendInt(b, int64(t.Day()), 10) 424 b = append(b, []byte{0x20}...) 425 b = append(b, id.monthsAbbreviated[t.Month()]...) 426 b = append(b, []byte{0x20}...) 427 428 if t.Year() > 0 { 429 b = strconv.AppendInt(b, int64(t.Year()), 10) 430 } else { 431 b = strconv.AppendInt(b, int64(-t.Year()), 10) 432 } 433 434 return string(b) 435} 436 437// FmtDateLong returns the long date representation of 't' for 'id' 438func (id *id) FmtDateLong(t time.Time) string { 439 440 b := make([]byte, 0, 32) 441 442 b = strconv.AppendInt(b, int64(t.Day()), 10) 443 b = append(b, []byte{0x20}...) 444 b = append(b, id.monthsWide[t.Month()]...) 445 b = append(b, []byte{0x20}...) 446 447 if t.Year() > 0 { 448 b = strconv.AppendInt(b, int64(t.Year()), 10) 449 } else { 450 b = strconv.AppendInt(b, int64(-t.Year()), 10) 451 } 452 453 return string(b) 454} 455 456// FmtDateFull returns the full date representation of 't' for 'id' 457func (id *id) FmtDateFull(t time.Time) string { 458 459 b := make([]byte, 0, 32) 460 461 b = append(b, id.daysWide[t.Weekday()]...) 462 b = append(b, []byte{0x2c, 0x20}...) 463 464 if t.Day() < 10 { 465 b = append(b, '0') 466 } 467 468 b = strconv.AppendInt(b, int64(t.Day()), 10) 469 b = append(b, []byte{0x20}...) 470 b = append(b, id.monthsWide[t.Month()]...) 471 b = append(b, []byte{0x20}...) 472 473 if t.Year() > 0 { 474 b = strconv.AppendInt(b, int64(t.Year()), 10) 475 } else { 476 b = strconv.AppendInt(b, int64(-t.Year()), 10) 477 } 478 479 return string(b) 480} 481 482// FmtTimeShort returns the short time representation of 't' for 'id' 483func (id *id) FmtTimeShort(t time.Time) string { 484 485 b := make([]byte, 0, 32) 486 487 if t.Hour() < 10 { 488 b = append(b, '0') 489 } 490 491 b = strconv.AppendInt(b, int64(t.Hour()), 10) 492 b = append(b, []byte{0x2e}...) 493 494 if t.Minute() < 10 { 495 b = append(b, '0') 496 } 497 498 b = strconv.AppendInt(b, int64(t.Minute()), 10) 499 500 return string(b) 501} 502 503// FmtTimeMedium returns the medium time representation of 't' for 'id' 504func (id *id) FmtTimeMedium(t time.Time) string { 505 506 b := make([]byte, 0, 32) 507 508 if t.Hour() < 10 { 509 b = append(b, '0') 510 } 511 512 b = strconv.AppendInt(b, int64(t.Hour()), 10) 513 b = append(b, []byte{0x2e}...) 514 515 if t.Minute() < 10 { 516 b = append(b, '0') 517 } 518 519 b = strconv.AppendInt(b, int64(t.Minute()), 10) 520 b = append(b, []byte{0x2e}...) 521 522 if t.Second() < 10 { 523 b = append(b, '0') 524 } 525 526 b = strconv.AppendInt(b, int64(t.Second()), 10) 527 528 return string(b) 529} 530 531// FmtTimeLong returns the long time representation of 't' for 'id' 532func (id *id) FmtTimeLong(t time.Time) string { 533 534 b := make([]byte, 0, 32) 535 536 if t.Hour() < 10 { 537 b = append(b, '0') 538 } 539 540 b = strconv.AppendInt(b, int64(t.Hour()), 10) 541 b = append(b, []byte{0x2e}...) 542 543 if t.Minute() < 10 { 544 b = append(b, '0') 545 } 546 547 b = strconv.AppendInt(b, int64(t.Minute()), 10) 548 b = append(b, []byte{0x2e}...) 549 550 if t.Second() < 10 { 551 b = append(b, '0') 552 } 553 554 b = strconv.AppendInt(b, int64(t.Second()), 10) 555 b = append(b, []byte{0x20}...) 556 557 tz, _ := t.Zone() 558 b = append(b, tz...) 559 560 return string(b) 561} 562 563// FmtTimeFull returns the full time representation of 't' for 'id' 564func (id *id) FmtTimeFull(t time.Time) string { 565 566 b := make([]byte, 0, 32) 567 568 if t.Hour() < 10 { 569 b = append(b, '0') 570 } 571 572 b = strconv.AppendInt(b, int64(t.Hour()), 10) 573 b = append(b, []byte{0x2e}...) 574 575 if t.Minute() < 10 { 576 b = append(b, '0') 577 } 578 579 b = strconv.AppendInt(b, int64(t.Minute()), 10) 580 b = append(b, []byte{0x2e}...) 581 582 if t.Second() < 10 { 583 b = append(b, '0') 584 } 585 586 b = strconv.AppendInt(b, int64(t.Second()), 10) 587 b = append(b, []byte{0x20}...) 588 589 tz, _ := t.Zone() 590 591 if btz, ok := id.timezones[tz]; ok { 592 b = append(b, btz...) 593 } else { 594 b = append(b, tz...) 595 } 596 597 return string(b) 598} 599