xsoh / moment-hijri

A Hijri calendar (Based on Umm al-Qura calculations) plugin for moment.js
http://momentjs.com/docs/#/plugins/hijri/
MIT License
200 stars 82 forks source link

Inconsistency when parsing month #83

Open alexfauquette opened 1 year ago

alexfauquette commented 1 year ago

I'm working on adapting the moment-hijri for mui date pickers, but I'm facing an issue when parsing months. the value is neither correctly recognized.

I made a codesandbox where I test if the function x => format(parse(format(x))) is the identity. But it's not the case.

With strict parsing, it's an invalid date and with loose parsing, it always returns 12

https://codesandbox.io/s/cranky-shadow-u3sv6g?file=/demo.tsx

Not sure if it's a bug or I'm using the library in a wrong way

anon-phantom commented 11 months ago

hey there,

Fixed the issue. Here's an updated sandbox code

https://codesandbox.io/s/hungry-joji-3y7gm5?file=/demo.tsx

**There is still an issue of month name doesn't correspond to actual month after parsing (woking on it).

anon-phantom commented 11 months ago

The array month naming in moment-hejri starts counting from 1, while in moment starts from 0

all issues fixed.

https://codesandbox.io/s/hungry-joji-3y7gm5?file=/demo.tsx

alexfauquette commented 11 months ago

Thanks

We will start again the migration of the adapter

anon-phantom commented 11 months ago

there was an issue with moment-hijri when used with @inertiajs/react

TypeError: moment.localeData is not a function

fixed it https://github.com/anon-phantom/hijri

mahmoudelgamal commented 1 month ago

there was an issue with moment-hijri when used with @inertiajs/react

TypeError: moment.localeData is not a function

fixed it https://github.com/anon-phantom/hijri

@anon-phantom the link is broken it's redirect me to 404 page