dua.go 17 KB

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