ar_KM.go 24 KB

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