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 1 commit
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
3 changes: 2 additions & 1 deletion web/src/components/ActivityCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const ActivityCalendar = (props: Props) => {
const year = dayjs(monthStr).toDate().getFullYear();
const month = dayjs(monthStr).toDate().getMonth() + 1;
const dayInMonth = new Date(year, month, 0).getDate();
const firstDay = (new Date(year, month - 1, 1).getDay() - weekStartDayOffset) % 7;
let firstDay = (new Date(year, month - 1, 1).getDay() - weekStartDayOffset) % 7;
if (firstDay < 0) firstDay += 7;
boojack marked this conversation as resolved.
Show resolved Hide resolved
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