Skip to content

Commit

Permalink
fix(#435): fix computation of number of weeks in a month
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed Aug 8, 2022
1 parent d29674d commit 11aa7e4
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/components/charts/MonthChart/formatMonthData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
addWeeks,
getDay,
getDaysInMonth,
getWeeksInMonth,
isSameWeek,
startOfMonth
} from 'date-fns';
import { addWeeks, getDay, getDaysInMonth, isSameWeek, startOfMonth } from 'date-fns';

import { DEFAULT_COMPLETION_NAME } from '../../../config/Constants';
import Completion from '../../../models/Completion';
Expand Down Expand Up @@ -35,7 +28,7 @@ const getWeekData = (

const formatData = (monthDate: Date, entries: TrackerEntry[]): DataType[] => {
const data = [];
const nbOfWeeks = getWeeksInMonth(monthDate);
const nbOfWeeks = Math.ceil(getDaysInMonth(monthDate) / 7);
const startDay = startOfMonth(monthDate);
for (let i = 0; i < nbOfWeeks; i += 1) {
const week = addWeeks(startDay, i);
Expand Down

0 comments on commit 11aa7e4

Please sign in to comment.