[
{
day: 1,
weekday: "Fri",
weeknumber: 1
},
{
day: 2,
weekday: "Sat",
weeknumber: false,
}
......
{
day: 4,
weekday: "Mon",
weeknumber: 2
},
{
day: 5,
weekday: "Tue",
weeknumber: false
}
]
function getDays(year, month) {
const days = [];
const d = new Date(year, month, 1);
let week = 1;
while (d.getMonth() === month) {
const date = d.getDate();
const day = d.getDay();
days.push({
day: date,
weeknumber: (day === 1 || date === 1) ? week : false,
weekday: d.toLocaleString('en-US', { weekday: 'short' }),
});
d.setDate(date + 1);
week += !day;
}
return days;
}
(+new Date() - +new Date(2020, 1, 1)) / 1000 / 60 / 60 / 24 / 7