Fix date loop with different timezone
parent
f9ca30c03c
commit
78669b88ff
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue