Reputation: 111
i have custom view like this:
views: {
dayGridMonthPersian:
{
type: "dayGrid",
buttonText: 'ماه شمسی',
visibleRange: function () {
const currentDate = new Date();
const thisMonthArray = GetStartEndMonth(currentDate);
return { start: thisMonthArray[0], end: thisMonthArray[1] }
},
},
In some Month everyThing is ok:
but in some Month I have Month Style Problem :
how can I fix this??
Upvotes: 3
Views: 775
Reputation: 111
may be useful for someOne. for First and last day of Persian Month :
function GetStartEndMonth(currentDate) {
const splitDate = splitGeorgianDateToPersianDateArray(currentDate);
const year = splitDate[0];
const month = splitDate[1];
const lastDayOfPersianMonth = GetLastDayOfPersianMonth(month, year);
//Not Work in some Month !! => moment(currentPersianDate).clone().startOf('month').format('YYYY/MM/DD');
//Not Work at All in persian => moment(currentPersianDate).clone().endof('month').format('YYYY/MM/DD');
const startPersianMonth = year + "/" + month + "/" + 1;
const endPersianMonth = year + "/" + month + "/" + lastDayOfPersianMonth;
let startGeorgianDate = ConvertPersianDateStringToGeorgianDate(startPersianMonth);
let endGeorgianDate = ConvertPersianDateStringToGeorgianDate(endPersianMonth);
endGeorgianDate.setHours(23, 59, 59, 59);
const newMonthArray = [startGeorgianDate, endGeorgianDate];
return newMonthArray;
}
function GetLastDayOfPersianMonth(month, year) {
//محاسبه کبیسه
const leapMatch = [1, 5, 9, 13, 17, 22, 26, 30];
const number = year % 33;
const isLeap = leapMatch.includes(number);
if (month <= 6) {
return 31;
}
if (month > 6 && month < 12) {
return 30;
}
if (month == 12 && !isLeap) {
return 29;
}
if (month == 12 && isLeap) {
return 30;
}
}
function splitGeorgianDateToPersianDateArray(georgianDate) {
const persianStringDate = moment(georgianDate).locale('fa').format('YYYY/M/D');
const splitDate = persianStringDate.split("/");
const year = splitDate[0];
const month = splitDate[1];
const day = splitDate[2];
return [year, month, day];
}
Upvotes: 3