nmg.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. package nmg
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type nmg 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. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyPositiveSuffix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'nmg' locale
  41. func New() locales.Translator {
  42. return &nmg{
  43. locale: "nmg",
  44. pluralsCardinal: nil,
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: ",",
  48. group: " ",
  49. timeSeparator: ":",
  50. 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 ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "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 ", "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 "},
  51. currencyPositiveSuffix: " ",
  52. currencyNegativeSuffix: " ",
  53. monthsAbbreviated: []string{"", "ng1", "ng2", "ng3", "ng4", "ng5", "ng6", "ng7", "ng8", "ng9", "ng10", "ng11", "kris"},
  54. monthsWide: []string{"", "ngwɛn matáhra", "ngwɛn ńmba", "ngwɛn ńlal", "ngwɛn ńna", "ngwɛn ńtan", "ngwɛn ńtuó", "ngwɛn hɛmbuɛrí", "ngwɛn lɔmbi", "ngwɛn rɛbvuâ", "ngwɛn wum", "ngwɛn wum navǔr", "krísimin"},
  55. daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "mbs", "sas"},
  56. daysNarrow: []string{"s", "m", "s", "s", "s", "m", "s"},
  57. daysWide: []string{"sɔ́ndɔ", "mɔ́ndɔ", "sɔ́ndɔ mafú mába", "sɔ́ndɔ mafú málal", "sɔ́ndɔ mafú mána", "mabágá má sukul", "sásadi"},
  58. periodsAbbreviated: []string{"maná", "kugú"},
  59. periodsWide: []string{"maná", "kugú"},
  60. erasAbbreviated: []string{"BL", "PB"},
  61. erasNarrow: []string{"", ""},
  62. erasWide: []string{"Bó Lahlɛ̄", "Pfiɛ Burī"},
  63. timezones: map[string]string{"AEST": "AEST", "CHADT": "CHADT", "WIB": "WIB", "CST": "CST", "MEZ": "MEZ", "AEDT": "AEDT", "ECT": "ECT", "CAT": "CAT", "SAST": "SAST", "GFT": "GFT", "SGT": "SGT", "HNT": "HNT", "WITA": "WITA", "LHST": "LHST", "JDT": "JDT", "NZST": "NZST", "EDT": "EDT", "HKT": "HKT", "WAT": "WAT", "WIT": "WIT", "LHDT": "LHDT", "CLST": "CLST", "WESZ": "WESZ", "EST": "EST", "GMT": "GMT", "HAT": "HAT", "COST": "COST", "HAST": "HAST", "ART": "ART", "TMT": "TMT", "TMST": "TMST", "BOT": "BOT", "CDT": "CDT", "WART": "WART", "WARST": "WARST", "AKST": "AKST", "CHAST": "CHAST", "ACWDT": "ACWDT", "ADT": "ADT", "GYT": "GYT", "MYT": "MYT", "VET": "VET", "COT": "COT", "∅∅∅": "∅∅∅", "SRT": "SRT", "UYT": "UYT", "MESZ": "MESZ", "AKDT": "AKDT", "PST": "PST", "ACWST": "ACWST", "HKST": "HKST", "OEZ": "OEZ", "ChST": "ChST", "ACST": "ACST", "MST": "MST", "UYST": "UYST", "WEZ": "WEZ", "OESZ": "OESZ", "JST": "JST", "MDT": "MDT", "AWDT": "AWDT", "PDT": "PDT", "BT": "BT", "EAT": "EAT", "ACDT": "ACDT", "HADT": "HADT", "WAST": "WAST", "IST": "IST", "ARST": "ARST", "AWST": "AWST", "AST": "AST", "NZDT": "NZDT", "CLT": "CLT"},
  64. }
  65. }
  66. // Locale returns the current translators string locale
  67. func (nmg *nmg) Locale() string {
  68. return nmg.locale
  69. }
  70. // PluralsCardinal returns the list of cardinal plural rules associated with 'nmg'
  71. func (nmg *nmg) PluralsCardinal() []locales.PluralRule {
  72. return nmg.pluralsCardinal
  73. }
  74. // PluralsOrdinal returns the list of ordinal plural rules associated with 'nmg'
  75. func (nmg *nmg) PluralsOrdinal() []locales.PluralRule {
  76. return nmg.pluralsOrdinal
  77. }
  78. // PluralsRange returns the list of range plural rules associated with 'nmg'
  79. func (nmg *nmg) PluralsRange() []locales.PluralRule {
  80. return nmg.pluralsRange
  81. }
  82. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nmg'
  83. func (nmg *nmg) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  84. return locales.PluralRuleUnknown
  85. }
  86. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nmg'
  87. func (nmg *nmg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  88. return locales.PluralRuleUnknown
  89. }
  90. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nmg'
  91. func (nmg *nmg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  92. return locales.PluralRuleUnknown
  93. }
  94. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  95. func (nmg *nmg) MonthAbbreviated(month time.Month) string {
  96. return nmg.monthsAbbreviated[month]
  97. }
  98. // MonthsAbbreviated returns the locales abbreviated months
  99. func (nmg *nmg) MonthsAbbreviated() []string {
  100. return nmg.monthsAbbreviated[1:]
  101. }
  102. // MonthNarrow returns the locales narrow month given the 'month' provided
  103. func (nmg *nmg) MonthNarrow(month time.Month) string {
  104. return nmg.monthsNarrow[month]
  105. }
  106. // MonthsNarrow returns the locales narrow months
  107. func (nmg *nmg) MonthsNarrow() []string {
  108. return nmg.monthsNarrow[1:]
  109. }
  110. // MonthWide returns the locales wide month given the 'month' provided
  111. func (nmg *nmg) MonthWide(month time.Month) string {
  112. return nmg.monthsWide[month]
  113. }
  114. // MonthsWide returns the locales wide months
  115. func (nmg *nmg) MonthsWide() []string {
  116. return nmg.monthsWide[1:]
  117. }
  118. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  119. func (nmg *nmg) WeekdayAbbreviated(weekday time.Weekday) string {
  120. return nmg.daysAbbreviated[weekday]
  121. }
  122. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  123. func (nmg *nmg) WeekdaysAbbreviated() []string {
  124. return nmg.daysAbbreviated
  125. }
  126. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  127. func (nmg *nmg) WeekdayNarrow(weekday time.Weekday) string {
  128. return nmg.daysNarrow[weekday]
  129. }
  130. // WeekdaysNarrow returns the locales narrow weekdays
  131. func (nmg *nmg) WeekdaysNarrow() []string {
  132. return nmg.daysNarrow
  133. }
  134. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  135. func (nmg *nmg) WeekdayShort(weekday time.Weekday) string {
  136. return nmg.daysShort[weekday]
  137. }
  138. // WeekdaysShort returns the locales short weekdays
  139. func (nmg *nmg) WeekdaysShort() []string {
  140. return nmg.daysShort
  141. }
  142. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  143. func (nmg *nmg) WeekdayWide(weekday time.Weekday) string {
  144. return nmg.daysWide[weekday]
  145. }
  146. // WeekdaysWide returns the locales wide weekdays
  147. func (nmg *nmg) WeekdaysWide() []string {
  148. return nmg.daysWide
  149. }
  150. // FmtNumber returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v'
  151. func (nmg *nmg) FmtNumber(num float64, v uint64) string {
  152. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  153. l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
  154. count := 0
  155. inWhole := v == 0
  156. b := make([]byte, 0, l)
  157. for i := len(s) - 1; i >= 0; i-- {
  158. if s[i] == '.' {
  159. b = append(b, nmg.decimal[0])
  160. inWhole = true
  161. continue
  162. }
  163. if inWhole {
  164. if count == 3 {
  165. for j := len(nmg.group) - 1; j >= 0; j-- {
  166. b = append(b, nmg.group[j])
  167. }
  168. count = 1
  169. } else {
  170. count++
  171. }
  172. }
  173. b = append(b, s[i])
  174. }
  175. if num < 0 {
  176. b = append(b, nmg.minus[0])
  177. }
  178. // reverse
  179. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  180. b[i], b[j] = b[j], b[i]
  181. }
  182. return string(b)
  183. }
  184. // FmtPercent returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v'
  185. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  186. func (nmg *nmg) FmtPercent(num float64, v uint64) string {
  187. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  188. l := len(s) + 1
  189. b := make([]byte, 0, l)
  190. for i := len(s) - 1; i >= 0; i-- {
  191. if s[i] == '.' {
  192. b = append(b, nmg.decimal[0])
  193. continue
  194. }
  195. b = append(b, s[i])
  196. }
  197. if num < 0 {
  198. b = append(b, nmg.minus[0])
  199. }
  200. // reverse
  201. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  202. b[i], b[j] = b[j], b[i]
  203. }
  204. b = append(b, nmg.percent...)
  205. return string(b)
  206. }
  207. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nmg'
  208. func (nmg *nmg) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  209. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  210. symbol := nmg.currencies[currency]
  211. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  212. count := 0
  213. inWhole := v == 0
  214. b := make([]byte, 0, l)
  215. for i := len(s) - 1; i >= 0; i-- {
  216. if s[i] == '.' {
  217. b = append(b, nmg.decimal[0])
  218. inWhole = true
  219. continue
  220. }
  221. if inWhole {
  222. if count == 3 {
  223. for j := len(nmg.group) - 1; j >= 0; j-- {
  224. b = append(b, nmg.group[j])
  225. }
  226. count = 1
  227. } else {
  228. count++
  229. }
  230. }
  231. b = append(b, s[i])
  232. }
  233. if num < 0 {
  234. b = append(b, nmg.minus[0])
  235. }
  236. // reverse
  237. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  238. b[i], b[j] = b[j], b[i]
  239. }
  240. if int(v) < 2 {
  241. if v == 0 {
  242. b = append(b, nmg.decimal...)
  243. }
  244. for i := 0; i < 2-int(v); i++ {
  245. b = append(b, '0')
  246. }
  247. }
  248. b = append(b, nmg.currencyPositiveSuffix...)
  249. b = append(b, symbol...)
  250. return string(b)
  251. }
  252. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nmg'
  253. // in accounting notation.
  254. func (nmg *nmg) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  255. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  256. symbol := nmg.currencies[currency]
  257. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  258. count := 0
  259. inWhole := v == 0
  260. b := make([]byte, 0, l)
  261. for i := len(s) - 1; i >= 0; i-- {
  262. if s[i] == '.' {
  263. b = append(b, nmg.decimal[0])
  264. inWhole = true
  265. continue
  266. }
  267. if inWhole {
  268. if count == 3 {
  269. for j := len(nmg.group) - 1; j >= 0; j-- {
  270. b = append(b, nmg.group[j])
  271. }
  272. count = 1
  273. } else {
  274. count++
  275. }
  276. }
  277. b = append(b, s[i])
  278. }
  279. if num < 0 {
  280. b = append(b, nmg.minus[0])
  281. }
  282. // reverse
  283. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  284. b[i], b[j] = b[j], b[i]
  285. }
  286. if int(v) < 2 {
  287. if v == 0 {
  288. b = append(b, nmg.decimal...)
  289. }
  290. for i := 0; i < 2-int(v); i++ {
  291. b = append(b, '0')
  292. }
  293. }
  294. if num < 0 {
  295. b = append(b, nmg.currencyNegativeSuffix...)
  296. b = append(b, symbol...)
  297. } else {
  298. b = append(b, nmg.currencyPositiveSuffix...)
  299. b = append(b, symbol...)
  300. }
  301. return string(b)
  302. }
  303. // FmtDateShort returns the short date representation of 't' for 'nmg'
  304. func (nmg *nmg) FmtDateShort(t time.Time) string {
  305. b := make([]byte, 0, 32)
  306. b = strconv.AppendInt(b, int64(t.Day()), 10)
  307. b = append(b, []byte{0x2f}...)
  308. b = strconv.AppendInt(b, int64(t.Month()), 10)
  309. b = append(b, []byte{0x2f}...)
  310. b = strconv.AppendInt(b, int64(t.Year()), 10)
  311. return string(b)
  312. }
  313. // FmtDateMedium returns the medium date representation of 't' for 'nmg'
  314. func (nmg *nmg) FmtDateMedium(t time.Time) string {
  315. b := make([]byte, 0, 32)
  316. b = strconv.AppendInt(b, int64(t.Day()), 10)
  317. b = append(b, []byte{0x20}...)
  318. b = append(b, nmg.monthsAbbreviated[t.Month()]...)
  319. b = append(b, []byte{0x20}...)
  320. b = strconv.AppendInt(b, int64(t.Year()), 10)
  321. return string(b)
  322. }
  323. // FmtDateLong returns the long date representation of 't' for 'nmg'
  324. func (nmg *nmg) FmtDateLong(t time.Time) string {
  325. b := make([]byte, 0, 32)
  326. b = strconv.AppendInt(b, int64(t.Day()), 10)
  327. b = append(b, []byte{0x20}...)
  328. b = append(b, nmg.monthsWide[t.Month()]...)
  329. b = append(b, []byte{0x20}...)
  330. b = strconv.AppendInt(b, int64(t.Year()), 10)
  331. return string(b)
  332. }
  333. // FmtDateFull returns the full date representation of 't' for 'nmg'
  334. func (nmg *nmg) FmtDateFull(t time.Time) string {
  335. b := make([]byte, 0, 32)
  336. b = append(b, nmg.daysWide[t.Weekday()]...)
  337. b = append(b, []byte{0x20}...)
  338. b = strconv.AppendInt(b, int64(t.Day()), 10)
  339. b = append(b, []byte{0x20}...)
  340. b = append(b, nmg.monthsWide[t.Month()]...)
  341. b = append(b, []byte{0x20}...)
  342. b = strconv.AppendInt(b, int64(t.Year()), 10)
  343. return string(b)
  344. }
  345. // FmtTimeShort returns the short time representation of 't' for 'nmg'
  346. func (nmg *nmg) FmtTimeShort(t time.Time) string {
  347. b := make([]byte, 0, 32)
  348. if t.Hour() < 10 {
  349. b = append(b, '0')
  350. }
  351. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  352. b = append(b, nmg.timeSeparator...)
  353. if t.Minute() < 10 {
  354. b = append(b, '0')
  355. }
  356. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  357. return string(b)
  358. }
  359. // FmtTimeMedium returns the medium time representation of 't' for 'nmg'
  360. func (nmg *nmg) FmtTimeMedium(t time.Time) string {
  361. b := make([]byte, 0, 32)
  362. if t.Hour() < 10 {
  363. b = append(b, '0')
  364. }
  365. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  366. b = append(b, nmg.timeSeparator...)
  367. if t.Minute() < 10 {
  368. b = append(b, '0')
  369. }
  370. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  371. b = append(b, nmg.timeSeparator...)
  372. if t.Second() < 10 {
  373. b = append(b, '0')
  374. }
  375. b = strconv.AppendInt(b, int64(t.Second()), 10)
  376. return string(b)
  377. }
  378. // FmtTimeLong returns the long time representation of 't' for 'nmg'
  379. func (nmg *nmg) FmtTimeLong(t time.Time) string {
  380. b := make([]byte, 0, 32)
  381. if t.Hour() < 10 {
  382. b = append(b, '0')
  383. }
  384. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  385. b = append(b, nmg.timeSeparator...)
  386. if t.Minute() < 10 {
  387. b = append(b, '0')
  388. }
  389. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  390. b = append(b, nmg.timeSeparator...)
  391. if t.Second() < 10 {
  392. b = append(b, '0')
  393. }
  394. b = strconv.AppendInt(b, int64(t.Second()), 10)
  395. b = append(b, []byte{0x20}...)
  396. tz, _ := t.Zone()
  397. b = append(b, tz...)
  398. return string(b)
  399. }
  400. // FmtTimeFull returns the full time representation of 't' for 'nmg'
  401. func (nmg *nmg) FmtTimeFull(t time.Time) string {
  402. b := make([]byte, 0, 32)
  403. if t.Hour() < 10 {
  404. b = append(b, '0')
  405. }
  406. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  407. b = append(b, nmg.timeSeparator...)
  408. if t.Minute() < 10 {
  409. b = append(b, '0')
  410. }
  411. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  412. b = append(b, nmg.timeSeparator...)
  413. if t.Second() < 10 {
  414. b = append(b, '0')
  415. }
  416. b = strconv.AppendInt(b, int64(t.Second()), 10)
  417. b = append(b, []byte{0x20}...)
  418. tz, _ := t.Zone()
  419. if btz, ok := nmg.timezones[tz]; ok {
  420. b = append(b, btz...)
  421. } else {
  422. b = append(b, tz...)
  423. }
  424. return string(b)
  425. }