(react) add a timezone props on date picker components

By default, component's timezone is the user locale timezone.
Component now offers a way to set its timezone to any supported
Intl timezone format. Please note that output values from the
component will always be converted to a UTC timezone.
This commit is contained in:
Lebaud Antoine
2023-07-24 22:02:55 +02:00
committed by aleb_the_flash
parent 0dc46d1144
commit cd42afb10e
8 changed files with 221 additions and 33 deletions

View File

@@ -29,6 +29,7 @@ export type DatePickerAuxSubProps = FieldProps & {
disabled?: boolean;
name?: string;
locale?: string;
timezone?: string;
};
export type DatePickerAuxProps = PropsWithChildren &
@@ -111,19 +112,28 @@ const DatePickerAux = forwardRef(
<input
type="hidden"
name={name && `${name}_start`}
value={convertDateValueToString(pickerState.value.start)}
value={convertDateValueToString(
pickerState.value.start,
props.timezone,
)}
/>
<input
type="hidden"
name={name && `${name}_end`}
value={convertDateValueToString(pickerState.value.end)}
value={convertDateValueToString(
pickerState.value.end,
props.timezone,
)}
/>
</>
) : (
<input
type="hidden"
name={name}
value={convertDateValueToString(pickerState.value)}
value={convertDateValueToString(
pickerState.value,
props.timezone,
)}
/>
)}
<div className="c__date-picker__wrapper__icon">