diff --git a/packages/date-picker/src/MonthCalendar.tsx b/packages/date-picker/src/MonthCalendar.tsx index e0f15ca2..3b1b09eb 100644 --- a/packages/date-picker/src/MonthCalendar.tsx +++ b/packages/date-picker/src/MonthCalendar.tsx @@ -3,7 +3,12 @@ import clsx from 'clsx'; import * as React from 'react'; import { ROOT_CLASS_NAME, STYLES } from './styles/month-calendar.js'; -import { getMonthFromDate, getMonthNameFromMonth, getYearFromMonth } from './utils.js'; +import { + getLastDateFromMonth, + getMonthFromDate, + getMonthNameFromMonth, + getYearFromMonth, +} from './utils.js'; export type Props = { className?: string; @@ -38,8 +43,7 @@ export default function MonthCalendar({ title = title ?? `${getMonthNameFromMonth(month)} ${year}`; const monthWithinYear = month % 12; const firstDate = new Date(year, monthWithinYear, 1); - const nextMonth = month + 1; - const lastDate = new Date(getYearFromMonth(nextMonth), nextMonth % 12, 1); + const lastDate = getLastDateFromMonth(month); lastDate.setDate(lastDate.getDate() - 1); const totalDays = lastDate.getDate(); const firstDay = firstDate.getDay();