Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi extend problem #27

Open
javadbat opened this issue Aug 31, 2020 · 3 comments
Open

multi extend problem #27

javadbat opened this issue Aug 31, 2020 · 3 comments

Comments

@javadbat
Copy link

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

@javadbat
Copy link
Author

i just fix it temporary by

if(typeof dayjs.isJalali == "function"){
    dayjs.extend(jalaliday);
}

@masoudelahi
Copy link

masoudelahi commented Oct 26, 2020

I have the same problem
I had set calendar to 'jalali'

i fix the problem by:

if (!dayjs.calendar) { dayjs.extend(jalaliday); }

@javadbat
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants