MCPcopy Index your code
hub / github.com/apitable/apitable / getPanelData

Function getPanelData

packages/components/src/components/calendar/utils.ts:104–143  ·  view source on GitHub ↗
(step: number)

Source from the content-addressed store, hash-verified

102 * @param step
103 */
104export const getPanelData = (step: number) => {
105 const now = new Date();
106 const currMonth = now.getMonth();
107 const totalMonth = step + currMonth + 1;
108 const year = now.getFullYear() + Math.ceil(totalMonth / 12) - 1;
109 let month = totalMonth % 12;
110 if (month <= 0) {
111 month += 12;
112 }
113 const days = daysInMonth(year, month + 1);
114 const preDays = daysInMonth(year, month);
115 const firstDay = firstDayOfMonth(year, month);
116 const data: { day: number, month: number }[] = [];
117 let i = 1;
118 const count = COUNT + (days + firstDay - 1 > COUNT ? 7 : 0);
119 while (count >= i) {
120 if (firstDay >= i + 1) {
121 data.push({
122 day: preDays - firstDay + i + 1,
123 month: month - 1
124 });
125 } else if (days < i + 1 - firstDay) {
126 data.push({
127 day: i + 1 - firstDay - days,
128 month: month + 1,
129 });
130 } else {
131 data.push({
132 day: i + 1 - firstDay,
133 month,
134 });
135 }
136 i++;
137 }
138 return {
139 data,
140 year,
141 month,
142 };
143};
144
145export const isMouseEvent = (event: MouseEvent | TouchEvent): event is MouseEvent => {
146 return Boolean(

Callers 2

CalendarFunction · 0.90
MonthBaseFunction · 0.90

Calls 3

daysInMonthFunction · 0.85
firstDayOfMonthFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected