yo_NG.go 18 KB

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