From a730db95dd9a55e4e3de39e0d420a55e47c4ba28 Mon Sep 17 00:00:00 2001 From: rsone001 Date: Fri, 13 Nov 2026 15:01:49 +0900 Subject: [PATCH] =?UTF-8?q?[ST]=20-=20fix:=20=EC=9E=85=EB=A0=A5=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EA=B8=B0=EA=B0=84=20=EC=97=B0=EB=8F=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatisticsInputPeriodDialog.tsx | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/apps/st/src/components/statistics/management/StatisticsInputPeriodDialog.tsx b/apps/st/src/components/statistics/management/StatisticsInputPeriodDialog.tsx index 6ebcfc66e..f560fd717 100644 --- a/apps/st/src/components/statistics/management/StatisticsInputPeriodDialog.tsx +++ b/apps/st/src/components/statistics/management/StatisticsInputPeriodDialog.tsx @@ -19,7 +19,6 @@ import { DialogHeader, DialogTitle, Input, - InputDatePicker, Label, Select, SelectContent, @@ -48,9 +47,32 @@ function normalizeStatsYrInput(raw: string): string { function formatDateToYmd(d: Date | undefined): string | null { if (!d || Number.isNaN(d.getTime())) return null; const y = d.getFullYear(); + if (y < 1000 || y > 9999) return null; const m = String(d.getMonth() + 1).padStart(2, "0"); const day = String(d.getDate()).padStart(2, "0"); - return `${y}${m}${day}`; + return `${String(y).padStart(4, "0")}${m}${day}`; +} + +/** Chrome `type="date"`는 max가 없으면 연도를 6자리까지 받음 */ +const PERIOD_DATE_INPUT_MIN = "1000-01-01"; +const PERIOD_DATE_INPUT_MAX = "9999-12-31"; + +function formatDateToInputValue(d: Date | undefined): string { + if (!d || Number.isNaN(d.getTime())) return ""; + const ymd = formatDateToYmd(d); + if (!ymd) return ""; + return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`; +} + +function parseFourDigitYearDate(raw: string): Date | undefined { + const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw); + if (!match) return undefined; + const year = Number(match[1]); + const month = Number(match[2]); + const day = Number(match[3]); + const parsed = new Date(year, month - 1, day); + if (Number.isNaN(parsed.getTime()) || parsed.getFullYear() !== year) return undefined; + return parsed; } export interface StatisticsInputPeriodDialogProps { @@ -281,18 +303,26 @@ export function StatisticsInputPeriodDialog({ )}
- setBgngYmd(parseFourDigitYearDate(e.target.value))} + disabled={isSubmitting} + className="!text-[1.3rem] w-full" />
- setEndYmd(parseFourDigitYearDate(e.target.value))} + disabled={isSubmitting} + className="!text-[1.3rem] w-full" />