/**
* Function to get details of next 2 months
* @returns {*[]}
*/
function getCurrentMonthDetails() {
try {
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const today = new Date();
const nextMonth = new Date(today.getFullYear(), today.getMonth() + 1, 1);
const weekdaysInMonth = [];
while (nextMonth.getMonth() === (today.getMonth() + 1) % 12 || nextMonth.getMonth() === (today.getMonth() + 2) % 12) {
let objDetails = {}
objDetails.weekday = weekdays[nextMonth.getDay()];
objDetails.weekdayNo = nextMonth.getDay() + 1;
let monthVal = nextMonth.getMonth() + 1;
objDetails.date = monthVal + "/" + nextMonth.getDate() + "/" + nextMonth.getFullYear();
weekdaysInMonth.push(objDetails);
nextMonth.setDate(nextMonth.getDate() + 1);
}
return weekdaysInMonth;
} catch (e) {
log.error("error@getCurrentMonthDetails", e);
return [];
}
}