jalaali / moment-jalaali

A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
MIT License
936 stars 162 forks source link

Feature Request - Adding daysInMonth for Shamsi Months #57

Closed MahdiMahzouni closed 8 years ago

MahdiMahzouni commented 8 years ago

Actual Behaviour : Right now when you call the daysInMonth method on a jalaali date it returns the maximum days of the Gregorian months ex. 31 and 30 or 28 . Appropriate Behaviour would be to return the correct days in Shamsi Calender like 31 and 30 for first half and last half of the year and 29 for the last month where the year is a leap year.

behrang commented 8 years ago

You can use jDaysInMonth. It was not documented. Added an example of it to the documentation.

behrang commented 8 years ago
moment.jDaysInMonth(1395, 11) // 30
moment.jDaysInMonth(1394, 11) // 29
matinzd commented 4 years ago

There is bug here ... moment('1399/1/10', 'jYYYY/jM/jD').daysInMonth() ---> Output : 31 moment('1399/2/10', 'jYYYY/jM/jD').daysInMonth() ---> Output : 30 !!! moment('1399/12/10', 'jYYYY/jM/jD').daysInMonth() ---> Output: 28 !!!

behrang commented 4 years ago

daysInMonth returns number of days in a Gregorian month. You may use moment.jDaysInMonth(1399, 0) to get the number of days in a specific Jalaali month. Note that months are 0-based.

matinzd commented 4 years ago

daysInMonth returns number of days in a Gregorian month. You may use moment.jDaysInMonth(1399, 0) to get the number of days in a specific Jalaali month. Note that months are 0-based.

Thanks!