I'm trying to either custom a pipe to convert numbers to Arabic or Persians, or find a function to convert numbers to Arabic numbers.
I've one function but it doesn't to give me a stable result,
for example I've this date : 1400/2/2 ---> ۲/۲/۱٤۰۰
arabicNumbers = ['۰', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
convertToArabic = (number) => {
return String(number).split('').map(char => {
if (char === '/') {
return '/';
} else {
return this.arabicNumbers[Number(char)]
}
}
).join('');
}
this function doesn't give a stable result, it keeps switching the numbers' order.
I hope you can help me solve this