Fixed issues with date time picker

This commit is contained in:
Jan Zípek 2022-08-24 22:40:26 +02:00
parent 39641194aa
commit ee2d4a52b0
Signed by: kamen
GPG Key ID: A17882625B33AC31
1 changed files with 8 additions and 2 deletions

View File

@ -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 (