diff --git a/web/src/components/kit/DatePicker.tsx b/web/src/components/kit/DatePicker.tsx index 5e73526e..d014bd6d 100644 --- a/web/src/components/kit/DatePicker.tsx +++ b/web/src/components/kit/DatePicker.tsx @@ -59,32 +59,30 @@ const DatePicker: React.FC = (props: DatePickerProps) => { handleDateStampChange(datestamp); }; - const handleChangeMonthBtnClick = (i: -1 | 1) => { - const year = firstDate.getFullYear(); - const month = firstDate.getMonth() + 1; - let nextDateStamp = 0; - if (month === 1 && i === -1) { - nextDateStamp = new Date(`${year - 1}/12/1`).getTime(); - } else if (month === 12 && i === 1) { - nextDateStamp = new Date(`${year + 1}/1/1`).getTime(); - } else { - nextDateStamp = new Date(`${year}/${month + i}/1`).getTime(); - } - setCurrentDateStamp(getMonthFirstDayDateStamp(nextDateStamp)); + const handleChangeMonthBtnClick = (i: number) => { + const nextDate = new Date(firstDate.getTime()); + nextDate.setMonth(nextDate.getMonth() + i); + setCurrentDateStamp(getMonthFirstDayDateStamp(nextDate.getTime())); }; return (
+ - {firstDate.getFullYear()}/{firstDate.getMonth() + 1} + {firstDate.getFullYear()}/{(firstDate.getMonth() + 1).toString().padStart(2, "0")} +