Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update first day logic for months starting on Sunday #3896

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/src/components/ActivityCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL).generalSetting || WorkspaceGeneralSetting.fromPartial({})
).weekStartDayOffset;
const year = dayjs(monthStr).toDate().getFullYear();
const month = dayjs(monthStr).toDate().getMonth() + 1;

Check failure on line 42 in web/src/components/ActivityCalendar.tsx

View workflow job for this annotation

GitHub Actions / static-checks

Replace `new·Date(year,·month·-·1,·1).getDay()·-·weekStartDayOffset)·%·7` with `(new·Date(year,·month·-·1,·1).getDay()·-·weekStartDayOffset)·%·7)`
const dayInMonth = new Date(year, month, 0).getDate();
const firstDay = (new Date(year, month - 1, 1).getDay() - weekStartDayOffset) % 7;
const firstDay = ((new Date(year, month - 1, 1).getDay() - weekStartDayOffset) % 7 + 7) % 7;
const lastDay = new Date(year, month - 1, dayInMonth).getDay() - weekStartDayOffset;
const weekDays = WEEK_DAYS.slice(weekStartDayOffset).concat(WEEK_DAYS.slice(0, weekStartDayOffset));
const maxCount = Math.max(...Object.values(data));
Expand Down
Loading