after looking web, i cant find any function to do this, i have personal solution that is work. Maybe it will be useful for someone.
**using Moment Plugin to Convert date. ***moment(currentPersianDate).clone().endof('month').format('YYYY/MM/DD') => not Work in Persian Date
function GetLastDayOfPersianMonth(calendar) {
const currentDate = new Date();
const currentPersianDate = moment(currentDate).locale('fa').format('YYYY/M/D');
const splitDate = currentPersianDate.split("/");
const year = splitDate[0];
const month = splitDate[1];
const lastDayOfPersianMonth = CalculateLeapYear(month, year);
const endPersianMonth = year + "/" + month + "/" + lastDayOfPersianMonth;
};
function CalculateLeapYear(month, year) {
if (month <= 6) {
return 31;
}
if (month > 6 && month < 12) {
return 30;
}
const leapMatch = [1, 5, 9, 13, 17, 22, 26, 30];
const number = year % 33;
const isLeap = leapMatch.includes(number);
if (month == 12 && !isLeap) {
return 29;
}
if (month == 12 && isLeap) {
return 30;
}
}