(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

@@ -38,10 +38,10 @@ export const DatePicker = (props: DatePickerProps) => {
// Force clear the component's value when passing null or an empty string.
props.value === "" || props.value === null
? null
: parseDateValue(props.value),
defaultValue: parseDateValue(props.defaultValue),
: parseDateValue(props.value, props.timezone),
defaultValue: parseDateValue(props.defaultValue, props.timezone),
onChange: (value: DateValue | null) => {
props.onChange?.(convertDateValueToString(value));
props.onChange?.(convertDateValueToString(value, props.timezone));
},
};
const pickerState = useDatePickerState(options);