diff --git a/component/calender/index.tsx b/component/calender/index.tsx index a1d8126..5ac1c0c 100644 --- a/component/calender/index.tsx +++ b/component/calender/index.tsx @@ -1,16 +1,24 @@ import React from "react"; import { Box, SimpleGrid } from "@chakra-ui/react"; +import { endOfMonth, getDate } from 'date-fns'; const Calender = (): JSX.Element => { + const today = new Date; + + const endOfCurrMonth = endOfMonth(today); + const lastDay = getDate(endOfCurrMonth); + + console.info(`This month has ${lastDay} days.`); + const daysArr = []; - for (let i = daysArr.length; i < 31; i++) { + for (let i = daysArr.length; i < lastDay; i++) { daysArr.push(daysArr.length + 1); } return ( { {daysArr.map((day) => { return (