DocSpace-buildtools/packages/components/calendar/utils/getCalendarMonths.js
2023-02-08 16:46:20 +05:00

22 lines
562 B
JavaScript

import moment from "moment";
export const getCalendarMonths = (observedDate) => {
const months = moment
.monthsShort()
.map((month) => (month[0].toUpperCase() + month.substring(1)));
const monthsObjs = months.map((month) => ({
key: `${observedDate.year()}-${moment().month(month).format("M")}`,
value: month,
}));
for (let i = 0; i < 4; i++) {
monthsObjs.push({
key: `${observedDate.year() + 1}-${moment()
.month(months[i])
.format("M")}`,
value: monthsObjs[i].value,
});
}
return monthsObjs;
};