ar_DZ.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. package ar_DZ
  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_DZ 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_DZ' locale
  41. func New() locales.Translator {
  42. return &ar_DZ{
  43. locale: "ar_DZ",
  44. pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{5, 6, 1, 4},
  47. decimal: ",",
  48. group: ".",
  49. minus: "‏-",
  50. percent: "٪",
  51. perMille: "؉",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. currencies: []string{"ADP ", "AED ", "AFA ", "AFN ", "ALK ", "ALL ", "AMD ", "ANG ", "AOA ", "AOK ", "AON ", "AOR ", "ARA ", "ARL ", "ARM ", "ARP ", "ARS ", "ATS ", "AUD ", "AWG ", "AZM ", "AZN ", "BAD ", "BAM ", "BAN ", "BBD ", "BDT ", "BEC ", "BEF ", "BEL ", "BGL ", "BGM ", "BGN ", "BGO ", "BHD ", "BIF ", "BMD ", "BND ", "BOB ", "BOL ", "BOP ", "BOV ", "BRB ", "BRC ", "BRE ", "BRL ", "BRN ", "BRR ", "BRZ ", "BSD ", "BTN ", "BUK ", "BWP ", "BYB ", "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{"WESZ": "توقيت غرب أوروبا الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "LHST": "توقيت لورد هاو الرسمي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CAT": "توقيت وسط أفريقيا", "BOT": "توقيت بوليفيا", "COST": "توقيت كولومبيا الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "GYT": "توقيت غيانا", "MYT": "توقيت ماليزيا", "JDT": "توقيت اليابان الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "MST": "MST", "TMT": "توقيت تركمانستان الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "ADT": "التوقيت الصيفي الأطلسي", "EAT": "توقيت شرق أفريقيا", "ACDT": "توقيت وسط أستراليا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "ChST": "توقيت تشامورو", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "WIT": "توقيت شرق إندونيسيا", "ART": "توقيت الأرجنتين الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CLST": "توقيت شيلي الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "MDT": "MDT", "TMST": "توقيت تركمانستان الصيفي", "UYT": "توقيت أورغواي الرسمي", "WITA": "توقيت وسط إندونيسيا", "SAST": "توقيت جنوب أفريقيا", "IST": "توقيت الهند", "VET": "توقيت فنزويلا", "SGT": "توقيت سنغافورة", "HADT": "توقيت هاواي ألوتيان الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "SRT": "توقيت سورينام", "JST": "توقيت اليابان الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "∅∅∅": "توقيت برازيليا الصيفي", "UYST": "توقيت أورغواي الصيفي", "BT": "توقيت بوتان", "OESZ": "توقيت شرق أوروبا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "GMT": "توقيت غرينتش", "MEZ": "توقيت وسط أوروبا الرسمي", "WIB": "توقيت غرب إندونيسيا", "AKST": "التوقيت الرسمي لألاسكا", "CHAST": "توقيت تشاتام الرسمي", "CLT": "توقيت شيلي الرسمي", "GFT": "توقيت غايانا الفرنسية", "WARST": "توقيت غرب الأرجنتين الصيفي", "AST": "التوقيت الرسمي الأطلسي", "HKST": "توقيت هونغ كونغ الصيفي", "HAT": "توقيت نيوفاوندلاند الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "ECT": "توقيت الإكوادور"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (ar *ar_DZ) Locale() string {
  75. return ar.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'ar_DZ'
  78. func (ar *ar_DZ) PluralsCardinal() []locales.PluralRule {
  79. return ar.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_DZ'
  82. func (ar *ar_DZ) PluralsOrdinal() []locales.PluralRule {
  83. return ar.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'ar_DZ'
  86. func (ar *ar_DZ) PluralsRange() []locales.PluralRule {
  87. return ar.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_DZ'
  90. func (ar *ar_DZ) 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_DZ'
  107. func (ar *ar_DZ) 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_DZ'
  111. func (ar *ar_DZ) 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_DZ) MonthAbbreviated(month time.Month) string {
  163. return ar.monthsAbbreviated[month]
  164. }
  165. // MonthsAbbreviated returns the locales abbreviated months
  166. func (ar *ar_DZ) MonthsAbbreviated() []string {
  167. return ar.monthsAbbreviated[1:]
  168. }
  169. // MonthNarrow returns the locales narrow month given the 'month' provided
  170. func (ar *ar_DZ) MonthNarrow(month time.Month) string {
  171. return ar.monthsNarrow[month]
  172. }
  173. // MonthsNarrow returns the locales narrow months
  174. func (ar *ar_DZ) MonthsNarrow() []string {
  175. return ar.monthsNarrow[1:]
  176. }
  177. // MonthWide returns the locales wide month given the 'month' provided
  178. func (ar *ar_DZ) MonthWide(month time.Month) string {
  179. return ar.monthsWide[month]
  180. }
  181. // MonthsWide returns the locales wide months
  182. func (ar *ar_DZ) MonthsWide() []string {
  183. return ar.monthsWide[1:]
  184. }
  185. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  186. func (ar *ar_DZ) WeekdayAbbreviated(weekday time.Weekday) string {
  187. return ar.daysAbbreviated[weekday]
  188. }
  189. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  190. func (ar *ar_DZ) WeekdaysAbbreviated() []string {
  191. return ar.daysAbbreviated
  192. }
  193. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  194. func (ar *ar_DZ) WeekdayNarrow(weekday time.Weekday) string {
  195. return ar.daysNarrow[weekday]
  196. }
  197. // WeekdaysNarrow returns the locales narrow weekdays
  198. func (ar *ar_DZ) WeekdaysNarrow() []string {
  199. return ar.daysNarrow
  200. }
  201. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  202. func (ar *ar_DZ) WeekdayShort(weekday time.Weekday) string {
  203. return ar.daysShort[weekday]
  204. }
  205. // WeekdaysShort returns the locales short weekdays
  206. func (ar *ar_DZ) WeekdaysShort() []string {
  207. return ar.daysShort
  208. }
  209. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  210. func (ar *ar_DZ) WeekdayWide(weekday time.Weekday) string {
  211. return ar.daysWide[weekday]
  212. }
  213. // WeekdaysWide returns the locales wide weekdays
  214. func (ar *ar_DZ) WeekdaysWide() []string {
  215. return ar.daysWide
  216. }
  217. // FmtNumber returns 'num' with digits/precision of 'v' for 'ar_DZ' and handles both Whole and Real numbers based on 'v'
  218. func (ar *ar_DZ) FmtNumber(num float64, v uint64) string {
  219. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  220. l := len(s) + 5 + 1*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. b = append(b, ar.decimal[0])
  227. inWhole = true
  228. continue
  229. }
  230. if inWhole {
  231. if count == 3 {
  232. b = append(b, ar.group[0])
  233. count = 1
  234. } else {
  235. count++
  236. }
  237. }
  238. b = append(b, s[i])
  239. }
  240. if num < 0 {
  241. for j := len(ar.minus) - 1; j >= 0; j-- {
  242. b = append(b, ar.minus[j])
  243. }
  244. }
  245. // reverse
  246. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  247. b[i], b[j] = b[j], b[i]
  248. }
  249. return string(b)
  250. }
  251. // FmtPercent returns 'num' with digits/precision of 'v' for 'ar_DZ' and handles both Whole and Real numbers based on 'v'
  252. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  253. func (ar *ar_DZ) FmtPercent(num float64, v uint64) string {
  254. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  255. l := len(s) + 7
  256. b := make([]byte, 0, l)
  257. for i := len(s) - 1; i >= 0; i-- {
  258. if s[i] == '.' {
  259. b = append(b, ar.decimal[0])
  260. continue
  261. }
  262. b = append(b, s[i])
  263. }
  264. if num < 0 {
  265. for j := len(ar.minus) - 1; j >= 0; j-- {
  266. b = append(b, ar.minus[j])
  267. }
  268. }
  269. // reverse
  270. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  271. b[i], b[j] = b[j], b[i]
  272. }
  273. b = append(b, ar.percent...)
  274. return string(b)
  275. }
  276. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DZ'
  277. func (ar *ar_DZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  278. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  279. symbol := ar.currencies[currency]
  280. l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3
  281. count := 0
  282. inWhole := v == 0
  283. b := make([]byte, 0, l)
  284. for i := len(s) - 1; i >= 0; i-- {
  285. if s[i] == '.' {
  286. b = append(b, ar.decimal[0])
  287. inWhole = true
  288. continue
  289. }
  290. if inWhole {
  291. if count == 3 {
  292. b = append(b, ar.group[0])
  293. count = 1
  294. } else {
  295. count++
  296. }
  297. }
  298. b = append(b, s[i])
  299. }
  300. for j := len(symbol) - 1; j >= 0; j-- {
  301. b = append(b, symbol[j])
  302. }
  303. for j := len(ar.currencyPositivePrefix) - 1; j >= 0; j-- {
  304. b = append(b, ar.currencyPositivePrefix[j])
  305. }
  306. if num < 0 {
  307. for j := len(ar.minus) - 1; j >= 0; j-- {
  308. b = append(b, ar.minus[j])
  309. }
  310. }
  311. // reverse
  312. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  313. b[i], b[j] = b[j], b[i]
  314. }
  315. if int(v) < 2 {
  316. if v == 0 {
  317. b = append(b, ar.decimal...)
  318. }
  319. for i := 0; i < 2-int(v); i++ {
  320. b = append(b, '0')
  321. }
  322. }
  323. return string(b)
  324. }
  325. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DZ'
  326. // in accounting notation.
  327. func (ar *ar_DZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  328. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  329. symbol := ar.currencies[currency]
  330. l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3
  331. count := 0
  332. inWhole := v == 0
  333. b := make([]byte, 0, l)
  334. for i := len(s) - 1; i >= 0; i-- {
  335. if s[i] == '.' {
  336. b = append(b, ar.decimal[0])
  337. inWhole = true
  338. continue
  339. }
  340. if inWhole {
  341. if count == 3 {
  342. b = append(b, ar.group[0])
  343. count = 1
  344. } else {
  345. count++
  346. }
  347. }
  348. b = append(b, s[i])
  349. }
  350. if num < 0 {
  351. for j := len(symbol) - 1; j >= 0; j-- {
  352. b = append(b, symbol[j])
  353. }
  354. for j := len(ar.currencyNegativePrefix) - 1; j >= 0; j-- {
  355. b = append(b, ar.currencyNegativePrefix[j])
  356. }
  357. for j := len(ar.minus) - 1; j >= 0; j-- {
  358. b = append(b, ar.minus[j])
  359. }
  360. } else {
  361. for j := len(symbol) - 1; j >= 0; j-- {
  362. b = append(b, symbol[j])
  363. }
  364. for j := len(ar.currencyPositivePrefix) - 1; j >= 0; j-- {
  365. b = append(b, ar.currencyPositivePrefix[j])
  366. }
  367. }
  368. // reverse
  369. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  370. b[i], b[j] = b[j], b[i]
  371. }
  372. if int(v) < 2 {
  373. if v == 0 {
  374. b = append(b, ar.decimal...)
  375. }
  376. for i := 0; i < 2-int(v); i++ {
  377. b = append(b, '0')
  378. }
  379. }
  380. return string(b)
  381. }
  382. // FmtDateShort returns the short date representation of 't' for 'ar_DZ'
  383. func (ar *ar_DZ) FmtDateShort(t time.Time) string {
  384. b := make([]byte, 0, 32)
  385. b = strconv.AppendInt(b, int64(t.Day()), 10)
  386. b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...)
  387. b = strconv.AppendInt(b, int64(t.Month()), 10)
  388. b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...)
  389. b = strconv.AppendInt(b, int64(t.Year()), 10)
  390. return string(b)
  391. }
  392. // FmtDateMedium returns the medium date representation of 't' for 'ar_DZ'
  393. func (ar *ar_DZ) FmtDateMedium(t time.Time) string {
  394. b := make([]byte, 0, 32)
  395. if t.Day() < 10 {
  396. b = append(b, '0')
  397. }
  398. b = strconv.AppendInt(b, int64(t.Day()), 10)
  399. b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...)
  400. if t.Month() < 10 {
  401. b = append(b, '0')
  402. }
  403. b = strconv.AppendInt(b, int64(t.Month()), 10)
  404. b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...)
  405. b = strconv.AppendInt(b, int64(t.Year()), 10)
  406. return string(b)
  407. }
  408. // FmtDateLong returns the long date representation of 't' for 'ar_DZ'
  409. func (ar *ar_DZ) FmtDateLong(t time.Time) string {
  410. b := make([]byte, 0, 32)
  411. b = strconv.AppendInt(b, int64(t.Day()), 10)
  412. b = append(b, []byte{0x20}...)
  413. b = append(b, ar.monthsWide[t.Month()]...)
  414. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  415. b = strconv.AppendInt(b, int64(t.Year()), 10)
  416. return string(b)
  417. }
  418. // FmtDateFull returns the full date representation of 't' for 'ar_DZ'
  419. func (ar *ar_DZ) FmtDateFull(t time.Time) string {
  420. b := make([]byte, 0, 32)
  421. b = append(b, ar.daysWide[t.Weekday()]...)
  422. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  423. b = strconv.AppendInt(b, int64(t.Day()), 10)
  424. b = append(b, []byte{0x20}...)
  425. b = append(b, ar.monthsWide[t.Month()]...)
  426. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  427. b = strconv.AppendInt(b, int64(t.Year()), 10)
  428. return string(b)
  429. }
  430. // FmtTimeShort returns the short time representation of 't' for 'ar_DZ'
  431. func (ar *ar_DZ) FmtTimeShort(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, ar.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, []byte{0x20}...)
  444. if t.Hour() < 12 {
  445. b = append(b, ar.periodsAbbreviated[0]...)
  446. } else {
  447. b = append(b, ar.periodsAbbreviated[1]...)
  448. }
  449. return string(b)
  450. }
  451. // FmtTimeMedium returns the medium time representation of 't' for 'ar_DZ'
  452. func (ar *ar_DZ) FmtTimeMedium(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, ar.timeSeparator...)
  465. if t.Second() < 10 {
  466. b = append(b, '0')
  467. }
  468. b = strconv.AppendInt(b, int64(t.Second()), 10)
  469. b = append(b, []byte{0x20}...)
  470. if t.Hour() < 12 {
  471. b = append(b, ar.periodsAbbreviated[0]...)
  472. } else {
  473. b = append(b, ar.periodsAbbreviated[1]...)
  474. }
  475. return string(b)
  476. }
  477. // FmtTimeLong returns the long time representation of 't' for 'ar_DZ'
  478. func (ar *ar_DZ) FmtTimeLong(t time.Time) string {
  479. b := make([]byte, 0, 32)
  480. h := t.Hour()
  481. if h > 12 {
  482. h -= 12
  483. }
  484. b = strconv.AppendInt(b, int64(h), 10)
  485. b = append(b, ar.timeSeparator...)
  486. if t.Minute() < 10 {
  487. b = append(b, '0')
  488. }
  489. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  490. b = append(b, ar.timeSeparator...)
  491. if t.Second() < 10 {
  492. b = append(b, '0')
  493. }
  494. b = strconv.AppendInt(b, int64(t.Second()), 10)
  495. b = append(b, []byte{0x20}...)
  496. if t.Hour() < 12 {
  497. b = append(b, ar.periodsAbbreviated[0]...)
  498. } else {
  499. b = append(b, ar.periodsAbbreviated[1]...)
  500. }
  501. b = append(b, []byte{0x20}...)
  502. tz, _ := t.Zone()
  503. b = append(b, tz...)
  504. return string(b)
  505. }
  506. // FmtTimeFull returns the full time representation of 't' for 'ar_DZ'
  507. func (ar *ar_DZ) FmtTimeFull(t time.Time) string {
  508. b := make([]byte, 0, 32)
  509. h := t.Hour()
  510. if h > 12 {
  511. h -= 12
  512. }
  513. b = strconv.AppendInt(b, int64(h), 10)
  514. b = append(b, ar.timeSeparator...)
  515. if t.Minute() < 10 {
  516. b = append(b, '0')
  517. }
  518. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  519. b = append(b, ar.timeSeparator...)
  520. if t.Second() < 10 {
  521. b = append(b, '0')
  522. }
  523. b = strconv.AppendInt(b, int64(t.Second()), 10)
  524. b = append(b, []byte{0x20}...)
  525. if t.Hour() < 12 {
  526. b = append(b, ar.periodsAbbreviated[0]...)
  527. } else {
  528. b = append(b, ar.periodsAbbreviated[1]...)
  529. }
  530. b = append(b, []byte{0x20}...)
  531. tz, _ := t.Zone()
  532. if btz, ok := ar.timezones[tz]; ok {
  533. b = append(b, btz...)
  534. } else {
  535. b = append(b, tz...)
  536. }
  537. return string(b)
  538. }