Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 7a69bab

Browse files
authored
fix(menu): simplify menu day check and adjust date comparison logic (#880)
2 parents 11dcd6a + e421e0b commit 7a69bab

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/services/pronote/menu.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ export const getMenu = async (account: PronoteAccount, date: Date): Promise<Menu
88
}
99

1010
const menu = await pronote.menus(account.instance, date);
11-
if (!menu.days || menu.days.length === 0) {
11+
if (!menu.days?.length) {
1212
return { date };
1313
}
14+
1415
const day = menu.days[0];
1516

16-
if (day.date?.getTime() !== date.getTime()) {
17+
const updatedDate = new Date(day.date);
18+
updatedDate.setDate(updatedDate.getDate() + 1);
19+
updatedDate.setUTCHours(0, 0, 0, 0);
20+
21+
const targetDate = new Date(date);
22+
targetDate.setUTCHours(0, 0, 0, 0);
23+
24+
if (updatedDate.getTime() !== targetDate.getTime()) {
1725
return { date };
1826
}
1927

0 commit comments

Comments
 (0)