react-datetime-picker
react-datetime-picker copied to clipboard
Tests fail due to running in different timezones
Hi, thank you for writing this great package!
As you mentioned here, you use local time only in order to match native browser inputs. However, this causes a problem with storybook snapshots, since the min and max values depend on the local timezone. So tests will fail when run in the wrong timezone.
I see how using the local date time makes sense for the individual inputs, but it doesn't quite make sense for the NativeInput component.
The simplest possible change would be to pass a UTC time ISO string to min, max, and value in the render method for NativeInput, instead of nativeValueParser. This would even simplify the onChangeNative method, but would not require any changes, and would not affect anything else (as far as I can tell).
We could even keep the default behavior completely unchanged by adding a new optional prop to decide whether to use UTC or local time. That way, this feature can be used only in cases where timezone issues arise.
I would be happy to open a PR and work on this change!