ha_GH.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. package ha_GH
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ha_GH 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. currencyPositivePrefix string
  23. currencyNegativePrefix 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 'ha_GH' locale
  41. func New() locales.Translator {
  42. return &ha_GH{
  43. locale: "ha_GH",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  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", "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", "GH₵", "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"},
  51. currencyPositivePrefix: " ",
  52. currencyNegativePrefix: " ",
  53. monthsAbbreviated: []string{"", "Jan", "Fab", "Mar", "Afi", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis"},
  54. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Y", "Y", "A", "S", "O", "N", "D"},
  55. monthsWide: []string{"", "Janairu", "Faburairu", "Maris", "Afirilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktoba", "Nuwamba", "Disamba"},
  56. daysAbbreviated: []string{"Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"},
  57. daysNarrow: []string{"L", "L", "T", "L", "A", "J", "A"},
  58. daysShort: []string{"Lh", "Li", "Ta", "Lr", "Al", "Ju", "As"},
  59. daysWide: []string{"Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Jummaʼa", "Asabar"},
  60. periodsAbbreviated: []string{"AM", "PM"},
  61. periodsNarrow: []string{"AM", "PM"},
  62. periodsWide: []string{"AM", "PM"},
  63. erasAbbreviated: []string{"KHAI", "BHAI"},
  64. erasNarrow: []string{"", ""},
  65. erasWide: []string{"Kafin haihuwar annab", "Bayan haihuwar annab"},
  66. timezones: map[string]string{"∅∅∅": "∅∅∅", "AEDT": "AEDT", "HECU": "HECU", "PDT": "PDT", "MYT": "MYT", "CLT": "CLT", "HADT": "HADT", "ACST": "ACST", "ACWST": "ACWST", "ACWDT": "ACWDT", "MEZ": "MEZ", "HAT": "HAT", "HNPM": "HNPM", "CLST": "CLST", "CST": "CST", "EST": "EST", "ACDT": "ACDT", "IST": "IST", "LHST": "LHST", "WARST": "WARST", "HENOMX": "HENOMX", "CAT": "CAT", "WESZ": "WESZ", "HEOG": "HEOG", "CHAST": "CHAST", "HNOG": "HNOG", "LHDT": "LHDT", "WIT": "WIT", "SAST": "SAST", "WIB": "WIB", "SGT": "SGT", "TMST": "TMST", "GMT": "GMT", "AST": "AST", "NZST": "NZST", "UYST": "UYST", "HNPMX": "HNPMX", "UYT": "UYT", "PST": "PST", "MDT": "MDT", "NZDT": "NZDT", "HEEG": "HEEG", "OESZ": "OESZ", "ART": "ART", "ADT": "ADT", "EDT": "EDT", "HNT": "HNT", "HEPM": "HEPM", "SRT": "SRT", "ARST": "ARST", "HEPMX": "HEPMX", "ChST": "ChST", "WAST": "WAST", "WEZ": "WEZ", "BT": "BT", "EAT": "EAT", "TMT": "TMT", "JDT": "JDT", "MESZ": "MESZ", "HKT": "HKT", "VET": "VET", "AEST": "AEST", "MST": "MST", "ECT": "ECT", "HNEG": "HNEG", "WITA": "WITA", "WAT": "WAT", "BOT": "BOT", "GYT": "GYT", "CHADT": "CHADT", "GFT": "GFT", "AKST": "AKST", "AKDT": "AKDT", "HNNOMX": "HNNOMX", "HAST": "HAST", "COT": "COT", "JST": "JST", "HKST": "HKST", "WART": "WART", "OEZ": "OEZ", "CDT": "CDT", "AWST": "AWST", "AWDT": "AWDT", "COST": "COST", "HNCU": "HNCU"},
  67. }
  68. }
  69. // Locale returns the current translators string locale
  70. func (ha *ha_GH) Locale() string {
  71. return ha.locale
  72. }
  73. // PluralsCardinal returns the list of cardinal plural rules associated with 'ha_GH'
  74. func (ha *ha_GH) PluralsCardinal() []locales.PluralRule {
  75. return ha.pluralsCardinal
  76. }
  77. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ha_GH'
  78. func (ha *ha_GH) PluralsOrdinal() []locales.PluralRule {
  79. return ha.pluralsOrdinal
  80. }
  81. // PluralsRange returns the list of range plural rules associated with 'ha_GH'
  82. func (ha *ha_GH) PluralsRange() []locales.PluralRule {
  83. return ha.pluralsRange
  84. }
  85. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ha_GH'
  86. func (ha *ha_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  87. n := math.Abs(num)
  88. if n == 1 {
  89. return locales.PluralRuleOne
  90. }
  91. return locales.PluralRuleOther
  92. }
  93. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ha_GH'
  94. func (ha *ha_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. return locales.PluralRuleUnknown
  96. }
  97. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ha_GH'
  98. func (ha *ha_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  99. return locales.PluralRuleUnknown
  100. }
  101. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  102. func (ha *ha_GH) MonthAbbreviated(month time.Month) string {
  103. return ha.monthsAbbreviated[month]
  104. }
  105. // MonthsAbbreviated returns the locales abbreviated months
  106. func (ha *ha_GH) MonthsAbbreviated() []string {
  107. return ha.monthsAbbreviated[1:]
  108. }
  109. // MonthNarrow returns the locales narrow month given the 'month' provided
  110. func (ha *ha_GH) MonthNarrow(month time.Month) string {
  111. return ha.monthsNarrow[month]
  112. }
  113. // MonthsNarrow returns the locales narrow months
  114. func (ha *ha_GH) MonthsNarrow() []string {
  115. return ha.monthsNarrow[1:]
  116. }
  117. // MonthWide returns the locales wide month given the 'month' provided
  118. func (ha *ha_GH) MonthWide(month time.Month) string {
  119. return ha.monthsWide[month]
  120. }
  121. // MonthsWide returns the locales wide months
  122. func (ha *ha_GH) MonthsWide() []string {
  123. return ha.monthsWide[1:]
  124. }
  125. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  126. func (ha *ha_GH) WeekdayAbbreviated(weekday time.Weekday) string {
  127. return ha.daysAbbreviated[weekday]
  128. }
  129. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  130. func (ha *ha_GH) WeekdaysAbbreviated() []string {
  131. return ha.daysAbbreviated
  132. }
  133. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  134. func (ha *ha_GH) WeekdayNarrow(weekday time.Weekday) string {
  135. return ha.daysNarrow[weekday]
  136. }
  137. // WeekdaysNarrow returns the locales narrow weekdays
  138. func (ha *ha_GH) WeekdaysNarrow() []string {
  139. return ha.daysNarrow
  140. }
  141. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  142. func (ha *ha_GH) WeekdayShort(weekday time.Weekday) string {
  143. return ha.daysShort[weekday]
  144. }
  145. // WeekdaysShort returns the locales short weekdays
  146. func (ha *ha_GH) WeekdaysShort() []string {
  147. return ha.daysShort
  148. }
  149. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  150. func (ha *ha_GH) WeekdayWide(weekday time.Weekday) string {
  151. return ha.daysWide[weekday]
  152. }
  153. // WeekdaysWide returns the locales wide weekdays
  154. func (ha *ha_GH) WeekdaysWide() []string {
  155. return ha.daysWide
  156. }
  157. // Decimal returns the decimal point of number
  158. func (ha *ha_GH) Decimal() string {
  159. return ha.decimal
  160. }
  161. // Group returns the group of number
  162. func (ha *ha_GH) Group() string {
  163. return ha.group
  164. }
  165. // Group returns the minus sign of number
  166. func (ha *ha_GH) Minus() string {
  167. return ha.minus
  168. }
  169. // FmtNumber returns 'num' with digits/precision of 'v' for 'ha_GH' and handles both Whole and Real numbers based on 'v'
  170. func (ha *ha_GH) FmtNumber(num float64, v uint64) string {
  171. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  172. l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3
  173. count := 0
  174. inWhole := v == 0
  175. b := make([]byte, 0, l)
  176. for i := len(s) - 1; i >= 0; i-- {
  177. if s[i] == '.' {
  178. b = append(b, ha.decimal[0])
  179. inWhole = true
  180. continue
  181. }
  182. if inWhole {
  183. if count == 3 {
  184. b = append(b, ha.group[0])
  185. count = 1
  186. } else {
  187. count++
  188. }
  189. }
  190. b = append(b, s[i])
  191. }
  192. if num < 0 {
  193. b = append(b, ha.minus[0])
  194. }
  195. // reverse
  196. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  197. b[i], b[j] = b[j], b[i]
  198. }
  199. return string(b)
  200. }
  201. // FmtPercent returns 'num' with digits/precision of 'v' for 'ha_GH' and handles both Whole and Real numbers based on 'v'
  202. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  203. func (ha *ha_GH) FmtPercent(num float64, v uint64) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. l := len(s) + 1
  206. b := make([]byte, 0, l)
  207. for i := len(s) - 1; i >= 0; i-- {
  208. if s[i] == '.' {
  209. b = append(b, ha.decimal[0])
  210. continue
  211. }
  212. b = append(b, s[i])
  213. }
  214. if num < 0 {
  215. b = append(b, ha.minus[0])
  216. }
  217. // reverse
  218. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  219. b[i], b[j] = b[j], b[i]
  220. }
  221. b = append(b, ha.percent...)
  222. return string(b)
  223. }
  224. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ha_GH'
  225. func (ha *ha_GH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  226. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  227. symbol := ha.currencies[currency]
  228. l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
  229. count := 0
  230. inWhole := v == 0
  231. b := make([]byte, 0, l)
  232. for i := len(s) - 1; i >= 0; i-- {
  233. if s[i] == '.' {
  234. b = append(b, ha.decimal[0])
  235. inWhole = true
  236. continue
  237. }
  238. if inWhole {
  239. if count == 3 {
  240. b = append(b, ha.group[0])
  241. count = 1
  242. } else {
  243. count++
  244. }
  245. }
  246. b = append(b, s[i])
  247. }
  248. for j := len(symbol) - 1; j >= 0; j-- {
  249. b = append(b, symbol[j])
  250. }
  251. for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- {
  252. b = append(b, ha.currencyPositivePrefix[j])
  253. }
  254. if num < 0 {
  255. b = append(b, ha.minus[0])
  256. }
  257. // reverse
  258. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  259. b[i], b[j] = b[j], b[i]
  260. }
  261. if int(v) < 2 {
  262. if v == 0 {
  263. b = append(b, ha.decimal...)
  264. }
  265. for i := 0; i < 2-int(v); i++ {
  266. b = append(b, '0')
  267. }
  268. }
  269. return string(b)
  270. }
  271. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ha_GH'
  272. // in accounting notation.
  273. func (ha *ha_GH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  274. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  275. symbol := ha.currencies[currency]
  276. l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
  277. count := 0
  278. inWhole := v == 0
  279. b := make([]byte, 0, l)
  280. for i := len(s) - 1; i >= 0; i-- {
  281. if s[i] == '.' {
  282. b = append(b, ha.decimal[0])
  283. inWhole = true
  284. continue
  285. }
  286. if inWhole {
  287. if count == 3 {
  288. b = append(b, ha.group[0])
  289. count = 1
  290. } else {
  291. count++
  292. }
  293. }
  294. b = append(b, s[i])
  295. }
  296. if num < 0 {
  297. for j := len(symbol) - 1; j >= 0; j-- {
  298. b = append(b, symbol[j])
  299. }
  300. for j := len(ha.currencyNegativePrefix) - 1; j >= 0; j-- {
  301. b = append(b, ha.currencyNegativePrefix[j])
  302. }
  303. b = append(b, ha.minus[0])
  304. } else {
  305. for j := len(symbol) - 1; j >= 0; j-- {
  306. b = append(b, symbol[j])
  307. }
  308. for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- {
  309. b = append(b, ha.currencyPositivePrefix[j])
  310. }
  311. }
  312. // reverse
  313. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  314. b[i], b[j] = b[j], b[i]
  315. }
  316. if int(v) < 2 {
  317. if v == 0 {
  318. b = append(b, ha.decimal...)
  319. }
  320. for i := 0; i < 2-int(v); i++ {
  321. b = append(b, '0')
  322. }
  323. }
  324. return string(b)
  325. }
  326. // FmtDateShort returns the short date representation of 't' for 'ha_GH'
  327. func (ha *ha_GH) FmtDateShort(t time.Time) string {
  328. b := make([]byte, 0, 32)
  329. b = strconv.AppendInt(b, int64(t.Day()), 10)
  330. b = append(b, []byte{0x2f}...)
  331. b = strconv.AppendInt(b, int64(t.Month()), 10)
  332. b = append(b, []byte{0x2f}...)
  333. if t.Year() > 9 {
  334. b = append(b, strconv.Itoa(t.Year())[2:]...)
  335. } else {
  336. b = append(b, strconv.Itoa(t.Year())[1:]...)
  337. }
  338. return string(b)
  339. }
  340. // FmtDateMedium returns the medium date representation of 't' for 'ha_GH'
  341. func (ha *ha_GH) FmtDateMedium(t time.Time) string {
  342. b := make([]byte, 0, 32)
  343. b = strconv.AppendInt(b, int64(t.Day()), 10)
  344. b = append(b, []byte{0x20}...)
  345. b = append(b, ha.monthsAbbreviated[t.Month()]...)
  346. b = append(b, []byte{0x2c, 0x20}...)
  347. if t.Year() > 0 {
  348. b = strconv.AppendInt(b, int64(t.Year()), 10)
  349. } else {
  350. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  351. }
  352. return string(b)
  353. }
  354. // FmtDateLong returns the long date representation of 't' for 'ha_GH'
  355. func (ha *ha_GH) FmtDateLong(t time.Time) string {
  356. b := make([]byte, 0, 32)
  357. b = strconv.AppendInt(b, int64(t.Day()), 10)
  358. b = append(b, []byte{0x20}...)
  359. b = append(b, ha.monthsWide[t.Month()]...)
  360. b = append(b, []byte{0x2c, 0x20}...)
  361. if t.Year() > 0 {
  362. b = strconv.AppendInt(b, int64(t.Year()), 10)
  363. } else {
  364. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  365. }
  366. return string(b)
  367. }
  368. // FmtDateFull returns the full date representation of 't' for 'ha_GH'
  369. func (ha *ha_GH) FmtDateFull(t time.Time) string {
  370. b := make([]byte, 0, 32)
  371. b = append(b, ha.daysWide[t.Weekday()]...)
  372. b = append(b, []byte{0x2c, 0x20}...)
  373. b = strconv.AppendInt(b, int64(t.Day()), 10)
  374. b = append(b, []byte{0x20}...)
  375. b = append(b, ha.monthsWide[t.Month()]...)
  376. b = append(b, []byte{0x2c, 0x20}...)
  377. if t.Year() > 0 {
  378. b = strconv.AppendInt(b, int64(t.Year()), 10)
  379. } else {
  380. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  381. }
  382. return string(b)
  383. }
  384. // FmtTimeShort returns the short time representation of 't' for 'ha_GH'
  385. func (ha *ha_GH) FmtTimeShort(t time.Time) string {
  386. b := make([]byte, 0, 32)
  387. if t.Hour() < 10 {
  388. b = append(b, '0')
  389. }
  390. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  391. b = append(b, ha.timeSeparator...)
  392. if t.Minute() < 10 {
  393. b = append(b, '0')
  394. }
  395. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  396. return string(b)
  397. }
  398. // FmtTimeMedium returns the medium time representation of 't' for 'ha_GH'
  399. func (ha *ha_GH) FmtTimeMedium(t time.Time) string {
  400. b := make([]byte, 0, 32)
  401. if t.Hour() < 10 {
  402. b = append(b, '0')
  403. }
  404. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  405. b = append(b, ha.timeSeparator...)
  406. if t.Minute() < 10 {
  407. b = append(b, '0')
  408. }
  409. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  410. b = append(b, ha.timeSeparator...)
  411. if t.Second() < 10 {
  412. b = append(b, '0')
  413. }
  414. b = strconv.AppendInt(b, int64(t.Second()), 10)
  415. return string(b)
  416. }
  417. // FmtTimeLong returns the long time representation of 't' for 'ha_GH'
  418. func (ha *ha_GH) FmtTimeLong(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, ha.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, ha.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. b = append(b, tz...)
  437. return string(b)
  438. }
  439. // FmtTimeFull returns the full time representation of 't' for 'ha_GH'
  440. func (ha *ha_GH) FmtTimeFull(t time.Time) string {
  441. b := make([]byte, 0, 32)
  442. if t.Hour() < 10 {
  443. b = append(b, '0')
  444. }
  445. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  446. b = append(b, ha.timeSeparator...)
  447. if t.Minute() < 10 {
  448. b = append(b, '0')
  449. }
  450. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  451. b = append(b, ha.timeSeparator...)
  452. if t.Second() < 10 {
  453. b = append(b, '0')
  454. }
  455. b = strconv.AppendInt(b, int64(t.Second()), 10)
  456. b = append(b, []byte{0x20}...)
  457. tz, _ := t.Zone()
  458. if btz, ok := ha.timezones[tz]; ok {
  459. b = append(b, btz...)
  460. } else {
  461. b = append(b, tz...)
  462. }
  463. return string(b)
  464. }