(step: number)
| 102 | * @param step |
| 103 | */ |
| 104 | export 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 | |
| 145 | export const isMouseEvent = (event: MouseEvent | TouchEvent): event is MouseEvent => { |
| 146 | return Boolean( |
no test coverage detected