lrc_IQ.go 18 KB

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