jalaliday
jalaliday copied to clipboard
multi extend problem
when I try to use jalaliday in a specific component I realize it converts my Jalali year 1399 to gregorian 3263 instead of 2020. as I check more I find out its a combination of webpack and your library problem. when someone import jalalidate in multiple modules in one special hierarchy and extend the original dayjs this library keep adding extra year in date convert process for example if I use this:
import dayjs from 'dayjs';
import jalaliday from 'jalaliday';
dayjs.extend(jalaliday);
dayjs.extend(jalaliday);
dayjs.extend(jalaliday);
the final result of dayjs(
1399-08-08, { jalali: true });
will be 4505
as you add more extend it add 621 years to the resulting year
3263->3884->4505->....
i think there must be a solution that multiple extend won't result in wrong date convert
i just fix it temporary by
if(typeof dayjs.isJalali == "function"){
dayjs.extend(jalaliday);
}
I have the same problem I had set calendar to 'jalali'
i fix the problem by:
if (!dayjs.calendar) { dayjs.extend(jalaliday); }
I have the same problem I had set calendar to 'jalali'
i fix the problem by:
if (!dayjs.calendar) { dayjs.extend(jalaliday); }
Yes I did the same for my calendar component https://www.npmjs.com/package/jb-date-input