'use client' import { CalendarIcon, X } from 'lucide-react' import { Button } from '@/components/ui/button' import { Calendar } from '@/components/ui/calendar' import { Input } from '@/components/ui/input' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import { cn } from '@/lib/utils' export type KriDateTimePickerProps = { value: string onChange: (value: string) => void placeholder?: string className?: string triggerClassName?: string contentClassName?: string disabled?: boolean } // value는 과 동일한 'yyyy-MM-ddTHH:mm' 포맷을 쓴다 const parseDateTime = (value: string): { date: Date | undefined; time: string } => { if (!value) return { date: undefined, time: '' } const [datePart, timePart = ''] = value.split('T') const [year, month, day] = datePart.split('-').map(Number) if (!year || !month || !day) return { date: undefined, time: timePart } const date = new Date(year, month - 1, day) if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) { return { date: undefined, time: timePart } } return { date, time: timePart } } const toValue = (date: Date | undefined, time: string): string => { if (!date) return '' const year = date.getFullYear() const month = String(date.getMonth() + 1).padStart(2, '0') const day = String(date.getDate()).padStart(2, '0') return `${year}-${month}-${day}T${time || '00:00'}` } export function KriDateTimePicker({ value, onChange, placeholder = '날짜/시간 선택', className, triggerClassName, contentClassName, disabled = false, }: KriDateTimePickerProps) { const { date, time } = parseDateTime(value) const hasValue = date !== undefined return (