fingerpich / jalali-moment

Display, parse, manipulate, validate and convert jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times.
https://fingerpich.github.io/jalali-moment/
MIT License
436 stars 68 forks source link

Wrong Result For jDay #101

Closed amirzenoozi closed 4 years ago

amirzenoozi commented 4 years ago

I use this Library for my jalali datePicker form field but when i update this library from v3.3.3 to v3.3.8 i found this bug:

Describe the bug when I try to get a last day of the month with this below code i get NaN:

const LastDayIndex = jMoment( '1399-4-31').locale('fa').jDay(); // NaN

// OR

const LastDayIndex = jMoment( '1399-4-' + jMoment.jDaysInMonth(1399, 4).toString() ).locale('fa').jDay(); // NaN

and I realize after update library the result of jDay() has one unit Increase. why?

fingerpich commented 4 years ago

please create a demo

https://stackblitz.com/edit/jalali-moment-demo-react-ed5qpt?file=index.js jday works well

jMoment( '1399-4-31') doesn't work because we updated the moment.js and it doesn't support this kind of input anymore. so please use the following syntax instead

jmoment.from("1399-4-14", 'fa', 'YYYY-MM-DD')