react-native-date-picker icon indicating copy to clipboard operation
react-native-date-picker copied to clipboard

onDateChange reverts to the previous value automatically after select date

Open rockstar0711 opened this issue 3 years ago • 2 comments

Describe the bug I could not select the date time properly because the picker reverts the value by the previous value.

Screenshot_2022_0907_082509 Screenshot_2022_0907_082220

Expected behavior Update the date value properly,

To Reproduce Add example code that reproduces the behavior.

const  TimePicker = ({date, mode}) => {

  // date props looks like below 
  // 2022-09-06T20:08:00.000Z

  const {authState} = useAuthData();
  const {themeState} = useThemeData();
  render = () =>
     <DatePicker
        date={new Date(date)}
        maximumDate={new Date()}
        onDateChange={e => {
          console.log('___', e);
          _onDateChange(e);
        }}
        is24hourSource="locale"
        locale={authState.data?.lang}
        mode={mode || 'datetime'}
        textColor={themeState.theme.PRIMARY_TEXT_COLOR}
        androidVariant="nativeAndroid"
      />

}

Smartphone (please complete the following information):

  • OS: Android
  • React Native version 0.64.2
  • react-native-date-picker version 3.4.3

rockstar0711 avatar Sep 07 '22 01:09 rockstar0711

Additionally, when remove the maximumDate prop in DatePicker component, such issue disappeared, after setup the maximumDate, this issue occurs again. 🤷‍♂️

rockstar0711 avatar Sep 07 '22 02:09 rockstar0711

I have worked so long time on this issue. I have found one interesting thing. If I setup the maximumDate by new Date(), then it occurs such issue like gif images above, but if I set up the maximumDate by new Date(moment().format(YYYY-MM-DD)) then this issue disappears. I got an idea while watching the doc of this package. this package recommend to use "YYYY-MM-DD" format for maximumDate. But for now, I cannot select times which are over a specific time like 08:00 even current time is 09:00 so I have setup the timeZoneOffsetInMinutes but still cannot select some minutes and seconds.

rockstar0711 avatar Sep 08 '22 00:09 rockstar0711

Yes this happens because maximumDate and minimumDate also takes hours and minutes into consideration. Make sure your Date object has hours and minutes set to 00:00 if that is what you want.

henninghall avatar Sep 30 '22 06:09 henninghall