bs_Latn.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. package bs_Latn
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type bs_Latn 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 'bs_Latn' locale
  42. func New() locales.Translator {
  43. return &bs_Latn{
  44. locale: "bs_Latn",
  45. pluralsCardinal: []locales.PluralRule{2, 4, 6},
  46. pluralsOrdinal: []locales.PluralRule{6},
  47. pluralsRange: []locales.PluralRule{2, 4, 6},
  48. decimal: ",",
  49. group: ".",
  50. minus: "-",
  51. percent: "%",
  52. perMille: "‰",
  53. timeSeparator: ":",
  54. inifinity: "∞",
  55. 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"},
  56. percentSuffix: " ",
  57. currencyPositiveSuffix: " ",
  58. currencyNegativeSuffix: " ",
  59. monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"},
  60. monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"},
  61. monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "juni", "juli", "avgust", "septembar", "oktobar", "novembar", "decembar"},
  62. daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
  63. daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"},
  64. daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
  65. daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"},
  66. periodsAbbreviated: []string{"prijepodne", "popodne"},
  67. periodsNarrow: []string{"prijepodne", "popodne"},
  68. periodsWide: []string{"prijepodne", "popodne"},
  69. erasAbbreviated: []string{"p. n. e.", "n. e."},
  70. erasNarrow: []string{"pr.n.e.", "AD"},
  71. erasWide: []string{"", ""},
  72. timezones: map[string]string{"LHDT": "Ljetno vrijeme na Ostrvu Lord Hau", "MDT": "Makao letnje računanje vremena", "HADT": "Havajsko-aleućansko ljetno vrijeme", "WEZ": "Zapadnoevropsko standardno vrijeme", "BOT": "Bolivijsko vrijeme", "GFT": "Francuskogvajansko vrijeme", "EST": "Sjevernoameričko istočno standardno vrijeme", "WITA": "Centralnoindonezijsko vrijeme", "UYST": "Urugvajsko ljetno vrijeme", "EAT": "Istočnoafričko vrijeme", "JDT": "Japansko ljetno vrijeme", "ACST": "Centralnoaustralijsko standardno vrijeme", "ACWDT": "Australijsko centralnozapadno ljetno vrijeme", "WIT": "Istočnoindonezijsko vrijeme", "CAT": "Centralnoafričko vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "MST": "Makao standardno vreme", "COST": "Kolumbijsko ljetno vrijeme", "HAST": "Havajsko-aleućansko standardno vrijeme", "PDT": "Sjevernoameričko pacifičko ljetno vrijeme", "WESZ": "Zapadnoevropsko ljetno vrijeme", "HNT": "Njufaundlendsko standardno vrijeme", "VET": "Venecuelansko vrijeme", "MESZ": "Centralnoevropsko ljetno vrijeme", "IST": "Indijsko standardno vrijeme", "HKST": "Hongkonško ljetno vrijeme", "CHAST": "Čatamsko standardno vrijeme", "CHADT": "Čatamsko ljetno vrijeme", "ACWST": "Australijsko centralnozapadno standardno vrijeme", "HNPM": "Standardno vrijeme na Ostrvima Sveti Petar i Mikelon", "HEPM": "Ljetno vrijeme na Ostrvima Sveti Petar i Mikelon", "CST": "Sjevernoameričko centralno standardno vrijeme", "AWST": "Zapadnoaustralijsko standardno vrijeme", "AEDT": "Istočnoaustralijsko ljetno vrijeme", "NZST": "Novozelandsko standardno vrijeme", "HEOG": "Zapadnogrenlandsko ljetno vrijeme", "TMT": "Turkmenistansko standardno vrijeme", "CLST": "Čileansko ljetno vrijeme", "EDT": "Sjevernoameričko istočno ljetno vrijeme", "AKST": "Aljaskansko standardno vrijeme", "HEEG": "Istočnogrenlandsko ljetno vrijeme", "AEST": "Istočnoaustralijsko standardno vrijeme", "WAT": "Zapadnoafričko standardno vrijeme", "MEZ": "Centralnoevropsko standardno vrijeme", "HAT": "Njufaundlendsko ljetno vrijeme", "UYT": "Urugvajsko standardno vrijeme", "GYT": "Gvajansko vrijeme", "PST": "Sjevernoameričko pacifičko standardno vrijeme", "WART": "Zapadnoargentinsko standardno vrijeme", "ARST": "Argentinsko ljetno vrijeme", "GMT": "Griničko vrijeme", "COT": "Kolumbijsko standardno vrijeme", "ADT": "Sjevernoameričko atlantsko ljetno vrijeme", "WAST": "Zapadnoafričko ljetno vrijeme", "ECT": "Ekvadorsko vrijeme", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "CLT": "Čileansko standardno vrijeme", "SAST": "Južnoafričko standardno vrijeme", "NZDT": "Novozelandsko ljetno vrijeme", "HNOG": "Zapadnogrenlandsko standardno vrijeme", "∅∅∅": "Amazonsko ljetno vrijeme", "CDT": "Sjevernoameričko centralno ljetno vrijeme", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "AST": "Sjevernoameričko atlantsko standardno vrijeme", "OESZ": "Istočnoevropsko ljetno vrijeme", "HECU": "Kubansko ljetno vrijeme", "ART": "Argentinsko standardno vrijeme", "HNCU": "Kubansko standardno vrijeme", "HNPMX": "Meksičko pacifičko standardno vrijeme", "HNEG": "Istočnogrenlandsko standardno vrijeme", "SRT": "Surinamsko vrijeme", "OEZ": "Istočnoevropsko standardno vrijeme", "AKDT": "Aljaskansko ljetno vrijeme", "HKT": "Hongkonško standardno vrijeme", "LHST": "Standardno vrijeme na Ostrvu Lord Hau", "WARST": "Zapadnoargentinsko ljetno vrijeme", "BT": "Butansko vrijeme", "MYT": "Malezijsko vrijeme", "AWDT": "Zapadnoaustralijsko ljetno vrijeme", "WIB": "Zapadnoindonezijsko vrijeme", "JST": "Japansko standardno vrijeme", "SGT": "Singapursko standardno vrijeme", "ACDT": "Centralnoaustralijsko ljetno vrijeme", "TMST": "Turkmenistansko ljetno vrijeme", "ChST": "Čamorsko standardno vrijeme"},
  73. }
  74. }
  75. // Locale returns the current translators string locale
  76. func (bs *bs_Latn) Locale() string {
  77. return bs.locale
  78. }
  79. // PluralsCardinal returns the list of cardinal plural rules associated with 'bs_Latn'
  80. func (bs *bs_Latn) PluralsCardinal() []locales.PluralRule {
  81. return bs.pluralsCardinal
  82. }
  83. // PluralsOrdinal returns the list of ordinal plural rules associated with 'bs_Latn'
  84. func (bs *bs_Latn) PluralsOrdinal() []locales.PluralRule {
  85. return bs.pluralsOrdinal
  86. }
  87. // PluralsRange returns the list of range plural rules associated with 'bs_Latn'
  88. func (bs *bs_Latn) PluralsRange() []locales.PluralRule {
  89. return bs.pluralsRange
  90. }
  91. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn'
  92. func (bs *bs_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  93. n := math.Abs(num)
  94. i := int64(n)
  95. f := locales.F(n, v)
  96. iMod10 := i % 10
  97. iMod100 := i % 100
  98. fMod10 := f % 10
  99. fMod100 := f % 100
  100. if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
  101. return locales.PluralRuleOne
  102. } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) {
  103. return locales.PluralRuleFew
  104. }
  105. return locales.PluralRuleOther
  106. }
  107. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn'
  108. func (bs *bs_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  109. return locales.PluralRuleOther
  110. }
  111. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs_Latn'
  112. func (bs *bs_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  113. start := bs.CardinalPluralRule(num1, v1)
  114. end := bs.CardinalPluralRule(num2, v2)
  115. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  116. return locales.PluralRuleOne
  117. } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
  118. return locales.PluralRuleFew
  119. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  120. return locales.PluralRuleOther
  121. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
  122. return locales.PluralRuleOne
  123. } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
  124. return locales.PluralRuleFew
  125. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
  126. return locales.PluralRuleOther
  127. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  128. return locales.PluralRuleOne
  129. } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
  130. return locales.PluralRuleFew
  131. }
  132. return locales.PluralRuleOther
  133. }
  134. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  135. func (bs *bs_Latn) MonthAbbreviated(month time.Month) string {
  136. return bs.monthsAbbreviated[month]
  137. }
  138. // MonthsAbbreviated returns the locales abbreviated months
  139. func (bs *bs_Latn) MonthsAbbreviated() []string {
  140. return bs.monthsAbbreviated[1:]
  141. }
  142. // MonthNarrow returns the locales narrow month given the 'month' provided
  143. func (bs *bs_Latn) MonthNarrow(month time.Month) string {
  144. return bs.monthsNarrow[month]
  145. }
  146. // MonthsNarrow returns the locales narrow months
  147. func (bs *bs_Latn) MonthsNarrow() []string {
  148. return bs.monthsNarrow[1:]
  149. }
  150. // MonthWide returns the locales wide month given the 'month' provided
  151. func (bs *bs_Latn) MonthWide(month time.Month) string {
  152. return bs.monthsWide[month]
  153. }
  154. // MonthsWide returns the locales wide months
  155. func (bs *bs_Latn) MonthsWide() []string {
  156. return bs.monthsWide[1:]
  157. }
  158. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  159. func (bs *bs_Latn) WeekdayAbbreviated(weekday time.Weekday) string {
  160. return bs.daysAbbreviated[weekday]
  161. }
  162. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  163. func (bs *bs_Latn) WeekdaysAbbreviated() []string {
  164. return bs.daysAbbreviated
  165. }
  166. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  167. func (bs *bs_Latn) WeekdayNarrow(weekday time.Weekday) string {
  168. return bs.daysNarrow[weekday]
  169. }
  170. // WeekdaysNarrow returns the locales narrow weekdays
  171. func (bs *bs_Latn) WeekdaysNarrow() []string {
  172. return bs.daysNarrow
  173. }
  174. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  175. func (bs *bs_Latn) WeekdayShort(weekday time.Weekday) string {
  176. return bs.daysShort[weekday]
  177. }
  178. // WeekdaysShort returns the locales short weekdays
  179. func (bs *bs_Latn) WeekdaysShort() []string {
  180. return bs.daysShort
  181. }
  182. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  183. func (bs *bs_Latn) WeekdayWide(weekday time.Weekday) string {
  184. return bs.daysWide[weekday]
  185. }
  186. // WeekdaysWide returns the locales wide weekdays
  187. func (bs *bs_Latn) WeekdaysWide() []string {
  188. return bs.daysWide
  189. }
  190. // Decimal returns the decimal point of number
  191. func (bs *bs_Latn) Decimal() string {
  192. return bs.decimal
  193. }
  194. // Group returns the group of number
  195. func (bs *bs_Latn) Group() string {
  196. return bs.group
  197. }
  198. // Group returns the minus sign of number
  199. func (bs *bs_Latn) Minus() string {
  200. return bs.minus
  201. }
  202. // FmtNumber returns 'num' with digits/precision of 'v' for 'bs_Latn' and handles both Whole and Real numbers based on 'v'
  203. func (bs *bs_Latn) FmtNumber(num float64, v uint64) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  206. count := 0
  207. inWhole := v == 0
  208. b := make([]byte, 0, l)
  209. for i := len(s) - 1; i >= 0; i-- {
  210. if s[i] == '.' {
  211. b = append(b, bs.decimal[0])
  212. inWhole = true
  213. continue
  214. }
  215. if inWhole {
  216. if count == 3 {
  217. b = append(b, bs.group[0])
  218. count = 1
  219. } else {
  220. count++
  221. }
  222. }
  223. b = append(b, s[i])
  224. }
  225. if num < 0 {
  226. b = append(b, bs.minus[0])
  227. }
  228. // reverse
  229. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  230. b[i], b[j] = b[j], b[i]
  231. }
  232. return string(b)
  233. }
  234. // FmtPercent returns 'num' with digits/precision of 'v' for 'bs_Latn' and handles both Whole and Real numbers based on 'v'
  235. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  236. func (bs *bs_Latn) FmtPercent(num float64, v uint64) string {
  237. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  238. l := len(s) + 5
  239. b := make([]byte, 0, l)
  240. for i := len(s) - 1; i >= 0; i-- {
  241. if s[i] == '.' {
  242. b = append(b, bs.decimal[0])
  243. continue
  244. }
  245. b = append(b, s[i])
  246. }
  247. if num < 0 {
  248. b = append(b, bs.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. b = append(b, bs.percentSuffix...)
  255. b = append(b, bs.percent...)
  256. return string(b)
  257. }
  258. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn'
  259. func (bs *bs_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  260. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  261. symbol := bs.currencies[currency]
  262. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  263. count := 0
  264. inWhole := v == 0
  265. b := make([]byte, 0, l)
  266. for i := len(s) - 1; i >= 0; i-- {
  267. if s[i] == '.' {
  268. b = append(b, bs.decimal[0])
  269. inWhole = true
  270. continue
  271. }
  272. if inWhole {
  273. if count == 3 {
  274. b = append(b, bs.group[0])
  275. count = 1
  276. } else {
  277. count++
  278. }
  279. }
  280. b = append(b, s[i])
  281. }
  282. if num < 0 {
  283. b = append(b, bs.minus[0])
  284. }
  285. // reverse
  286. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  287. b[i], b[j] = b[j], b[i]
  288. }
  289. if int(v) < 2 {
  290. if v == 0 {
  291. b = append(b, bs.decimal...)
  292. }
  293. for i := 0; i < 2-int(v); i++ {
  294. b = append(b, '0')
  295. }
  296. }
  297. b = append(b, bs.currencyPositiveSuffix...)
  298. b = append(b, symbol...)
  299. return string(b)
  300. }
  301. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn'
  302. // in accounting notation.
  303. func (bs *bs_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  304. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  305. symbol := bs.currencies[currency]
  306. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  307. count := 0
  308. inWhole := v == 0
  309. b := make([]byte, 0, l)
  310. for i := len(s) - 1; i >= 0; i-- {
  311. if s[i] == '.' {
  312. b = append(b, bs.decimal[0])
  313. inWhole = true
  314. continue
  315. }
  316. if inWhole {
  317. if count == 3 {
  318. b = append(b, bs.group[0])
  319. count = 1
  320. } else {
  321. count++
  322. }
  323. }
  324. b = append(b, s[i])
  325. }
  326. if num < 0 {
  327. b = append(b, bs.minus[0])
  328. }
  329. // reverse
  330. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  331. b[i], b[j] = b[j], b[i]
  332. }
  333. if int(v) < 2 {
  334. if v == 0 {
  335. b = append(b, bs.decimal...)
  336. }
  337. for i := 0; i < 2-int(v); i++ {
  338. b = append(b, '0')
  339. }
  340. }
  341. if num < 0 {
  342. b = append(b, bs.currencyNegativeSuffix...)
  343. b = append(b, symbol...)
  344. } else {
  345. b = append(b, bs.currencyPositiveSuffix...)
  346. b = append(b, symbol...)
  347. }
  348. return string(b)
  349. }
  350. // FmtDateShort returns the short date representation of 't' for 'bs_Latn'
  351. func (bs *bs_Latn) FmtDateShort(t time.Time) string {
  352. b := make([]byte, 0, 32)
  353. b = strconv.AppendInt(b, int64(t.Day()), 10)
  354. b = append(b, []byte{0x2e}...)
  355. b = strconv.AppendInt(b, int64(t.Month()), 10)
  356. b = append(b, []byte{0x2e}...)
  357. if t.Year() > 9 {
  358. b = append(b, strconv.Itoa(t.Year())[2:]...)
  359. } else {
  360. b = append(b, strconv.Itoa(t.Year())[1:]...)
  361. }
  362. b = append(b, []byte{0x2e}...)
  363. return string(b)
  364. }
  365. // FmtDateMedium returns the medium date representation of 't' for 'bs_Latn'
  366. func (bs *bs_Latn) FmtDateMedium(t time.Time) string {
  367. b := make([]byte, 0, 32)
  368. b = strconv.AppendInt(b, int64(t.Day()), 10)
  369. b = append(b, []byte{0x2e, 0x20}...)
  370. b = append(b, bs.monthsAbbreviated[t.Month()]...)
  371. b = append(b, []byte{0x20}...)
  372. if t.Year() > 0 {
  373. b = strconv.AppendInt(b, int64(t.Year()), 10)
  374. } else {
  375. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  376. }
  377. b = append(b, []byte{0x2e}...)
  378. return string(b)
  379. }
  380. // FmtDateLong returns the long date representation of 't' for 'bs_Latn'
  381. func (bs *bs_Latn) FmtDateLong(t time.Time) string {
  382. b := make([]byte, 0, 32)
  383. b = strconv.AppendInt(b, int64(t.Day()), 10)
  384. b = append(b, []byte{0x2e, 0x20}...)
  385. b = append(b, bs.monthsWide[t.Month()]...)
  386. b = append(b, []byte{0x20}...)
  387. if t.Year() > 0 {
  388. b = strconv.AppendInt(b, int64(t.Year()), 10)
  389. } else {
  390. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  391. }
  392. b = append(b, []byte{0x2e}...)
  393. return string(b)
  394. }
  395. // FmtDateFull returns the full date representation of 't' for 'bs_Latn'
  396. func (bs *bs_Latn) FmtDateFull(t time.Time) string {
  397. b := make([]byte, 0, 32)
  398. b = append(b, bs.daysWide[t.Weekday()]...)
  399. b = append(b, []byte{0x2c, 0x20}...)
  400. b = strconv.AppendInt(b, int64(t.Day()), 10)
  401. b = append(b, []byte{0x2e, 0x20}...)
  402. b = append(b, bs.monthsWide[t.Month()]...)
  403. b = append(b, []byte{0x20}...)
  404. if t.Year() > 0 {
  405. b = strconv.AppendInt(b, int64(t.Year()), 10)
  406. } else {
  407. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  408. }
  409. b = append(b, []byte{0x2e}...)
  410. return string(b)
  411. }
  412. // FmtTimeShort returns the short time representation of 't' for 'bs_Latn'
  413. func (bs *bs_Latn) FmtTimeShort(t time.Time) string {
  414. b := make([]byte, 0, 32)
  415. if t.Hour() < 10 {
  416. b = append(b, '0')
  417. }
  418. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  419. b = append(b, bs.timeSeparator...)
  420. if t.Minute() < 10 {
  421. b = append(b, '0')
  422. }
  423. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  424. return string(b)
  425. }
  426. // FmtTimeMedium returns the medium time representation of 't' for 'bs_Latn'
  427. func (bs *bs_Latn) FmtTimeMedium(t time.Time) string {
  428. b := make([]byte, 0, 32)
  429. if t.Hour() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  433. b = append(b, bs.timeSeparator...)
  434. if t.Minute() < 10 {
  435. b = append(b, '0')
  436. }
  437. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  438. b = append(b, bs.timeSeparator...)
  439. if t.Second() < 10 {
  440. b = append(b, '0')
  441. }
  442. b = strconv.AppendInt(b, int64(t.Second()), 10)
  443. return string(b)
  444. }
  445. // FmtTimeLong returns the long time representation of 't' for 'bs_Latn'
  446. func (bs *bs_Latn) FmtTimeLong(t time.Time) string {
  447. b := make([]byte, 0, 32)
  448. if t.Hour() < 10 {
  449. b = append(b, '0')
  450. }
  451. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  452. b = append(b, bs.timeSeparator...)
  453. if t.Minute() < 10 {
  454. b = append(b, '0')
  455. }
  456. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  457. b = append(b, bs.timeSeparator...)
  458. if t.Second() < 10 {
  459. b = append(b, '0')
  460. }
  461. b = strconv.AppendInt(b, int64(t.Second()), 10)
  462. b = append(b, []byte{0x20}...)
  463. tz, _ := t.Zone()
  464. b = append(b, tz...)
  465. return string(b)
  466. }
  467. // FmtTimeFull returns the full time representation of 't' for 'bs_Latn'
  468. func (bs *bs_Latn) FmtTimeFull(t time.Time) string {
  469. b := make([]byte, 0, 32)
  470. if t.Hour() < 10 {
  471. b = append(b, '0')
  472. }
  473. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  474. b = append(b, bs.timeSeparator...)
  475. if t.Minute() < 10 {
  476. b = append(b, '0')
  477. }
  478. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  479. b = append(b, bs.timeSeparator...)
  480. if t.Second() < 10 {
  481. b = append(b, '0')
  482. }
  483. b = strconv.AppendInt(b, int64(t.Second()), 10)
  484. b = append(b, []byte{0x20}...)
  485. tz, _ := t.Zone()
  486. if btz, ok := bs.timezones[tz]; ok {
  487. b = append(b, btz...)
  488. } else {
  489. b = append(b, tz...)
  490. }
  491. return string(b)
  492. }