ar_MR.go 25 KB

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