ar_AE.go 24 KB

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