Fixed issues with date time picker
This commit is contained in:
parent
39641194aa
commit
ee2d4a52b0
|
|
@ -11,15 +11,21 @@ export const DateTimeInput = ({ value, onChange }: Props) => {
|
|||
const handleDateChange = (e: Event) => {
|
||||
const target = e.target as HTMLInputElement
|
||||
const value = target.value
|
||||
const newDate = new Date(`${value || splitValue[0]} ${splitValue[1]}`)
|
||||
|
||||
onChange(new Date(`${value} ${splitValue[1]}`))
|
||||
if (!isNaN(newDate.getTime())) {
|
||||
onChange(newDate)
|
||||
}
|
||||
}
|
||||
|
||||
const handleTimeChange = (e: Event) => {
|
||||
const target = e.target as HTMLInputElement
|
||||
const value = target.value
|
||||
const newDate = new Date(`${splitValue[0]} ${value || splitValue[1]}`)
|
||||
|
||||
onChange(new Date(`${splitValue[0]} ${value}`))
|
||||
if (!isNaN(newDate.getTime())) {
|
||||
onChange(newDate)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue