rn.go 16 KB

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