I used moment to format date strings for a lot of different languages. Now I want to migrate from moment to dayjs so I created a new function that should create me localized date strings like this:
import * as dayjs from 'dayjs';
import * as localizedFormat from 'dayjs/plugin/localizedFormat';
import 'dayjs/locale/ar';
// ... 57 more locales
dayjs.extend(localizedFormat);
const formatDate = (date:Date, locale:string) => {
return dayjs(date).locale(locale).format("L");
};
for 42 locales it works fine but the ones with e.g. asian or arabic characters are not properly displayed. When I did the same previously with moment using moment(date).locale(locale).format("L") instead I got a proper response. For e.g. arabic(ar) I got with moment ١٧/١/٢٠٢٢ and with dayjs 01/17/2022 but if I open the imported locale in dayjs/locale/ar I can see that they have strings with these characters in place and just don't use them.
This happens for ar, bn, fa, hi, km, my, pa, si and a couple of other ones that have e.g. days and months twisted, but that I could change myself.
Is there anything I do wrong?
Thanks in advance :)