Fix date loop with different timezone

pull/2827/head
Jérémy Rialland 2023-09-27 15:27:37 -02:00 committed by Jérémy Rialland
parent f9ca30c03c
commit 78669b88ff
2 changed files with 5 additions and 4 deletions

View File

@ -30,7 +30,7 @@ export default function DateInput({
}
const [day, month, year] = val.split('/')
return `${year}-${month}-${day}`
return `${year}-${month}-${day}T12:00:00`
}
const handleDateChange = useCallback(
@ -68,7 +68,7 @@ export default function DateInput({
<Suspense fallback={<DateFieldFallback />}>
<DateField
defaultSelected={
(missing && hideDefaultValue) || !isNaN(+dateValue)
(missing && hideDefaultValue) || isNaN(+dateValue)
? undefined
: dateValue
}

View File

@ -50,11 +50,12 @@ export default function DateField(props: DateFieldProps) {
const id = useId()
const format = 'dd/MM/y'
const locale = language === 'fr' ? fr : enUS
const { inputProps, dayPickerProps } = useInput({
defaultSelected,
format,
required: true,
locale: language === 'fr' ? fr : enUS,
locale,
fromDate: type === 'date futur' ? new Date() : new Date('1800-01-01'),
toDate:
type === 'date passé'
@ -115,7 +116,7 @@ export default function DateField(props: DateFieldProps) {
setSelected(date)
if (date) {
const value = formatDate(date, format)
const value = formatDate(date, format, { locale })
setInputValue(value)
close()
onChange?.(value)