naq.go 17 KB

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