calidy-com / dayjs-calendarsystems

Day.js Calendar Systems Plugin : extends Day.js library to allow the use of non-gregorian calendar systems.
Other
16 stars 3 forks source link

Setting default dayjs config (for all following instances) to a specific calendar system doesn't seem to do anything #3

Closed blazk0 closed 2 months ago

blazk0 commented 5 months ago

Hello,

First of all, Thanks a lot for this repo. It integrates pretty well with dayjs.

Now, I have a file named dayjs.ts where all dayjs config is present.

import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import relativeTime from 'dayjs/plugin/relativeTime';
import localizedFormat from 'dayjs/plugin/localizedFormat';

import calendarSystems from "@calidy/dayjs-calendarsystems";
import HijriCalendarSystem from "@calidy/dayjs-calendarsystems/calendarSystems/HijriCalendarSystem";

dayjs.extend(localeData);
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);

dayjs.extend(calendarSystems)
dayjs.registerCalendarSystem("islamic", new HijriCalendarSystem());

dayjs.toCalendarSystem('islamic')

export { dayjs }

Changing dayjs.toCalendarSystem('islamic') to dayjs().toCalendarSystem('islamic') changes things a bit but not correctly unfortunately which is strange i thought this was to a specific instance only ?

Is there any way to change dayjs config globally or do i have to do it for every instance separately ?

Thanks in Advance

amirhmoradi commented 5 months ago

Hi @blazk0 , thanks for your message. If i understood correctly, you need the global dayjs object to be in hijri calendar system. You mentioned the fact that things change a bit but not correctly, can you please give me some examples and what is the correct expected output so I can work from there?

Best.

amirhmoradi commented 2 months ago

@blazk0 Hi, any updates on this? I will close this issue due to inactivity. If you need to reopen it, please let me know with a comment.