function to generate array of months from selected date was created
This commit is contained in:
parent
87ce705f19
commit
e289c4a0a4
17
packages/components/calendar/utils/getCalendarMonths.js
Normal file
17
packages/components/calendar/utils/getCalendarMonths.js
Normal file
@ -0,0 +1,17 @@
|
||||
import moment from "moment";
|
||||
|
||||
export const getCalendarMonths = (selectedDate) => {
|
||||
// prettier-ignore
|
||||
const months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr"];
|
||||
const monthsObjs = months.map((month) => ({
|
||||
key: `${selectedDate.year()}-${moment().month(month).format("M")}`,
|
||||
value: month,
|
||||
}));
|
||||
for (let i = 12; i < 16; i++) {
|
||||
monthsObjs[i] = {
|
||||
key: `${selectedDate.year() + 1}` + monthsObjs[i].key.substring(4),
|
||||
value: monthsObjs[i].value,
|
||||
};
|
||||
}
|
||||
return monthsObjs;
|
||||
};
|
Loading…
Reference in New Issue
Block a user