Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimumDate with minuteInterval uses the last valid time instead of the one selected automatically #721

Closed
cosminpwd opened this issue Nov 1, 2023 · 10 comments

Comments

@cosminpwd
Copy link

cosminpwd commented Nov 1, 2023

Describe the bug
When I use minimumDate with minuteInterval in a modal and I select the minimum date, it automatically increases by minuteInterval. But when I confirm onConfirm returns the last valid time instead of what was set automatically.

For example, with minimumDate=8:00am and minuteInterval=5 I select 7:00pm then 7:00am. This triggers minimumDate and it changes to 8:05am, the next possible value with minuteInterval. Now onConfirm returns 7:00pm instead of 8:05am.

Expected behavior
onConfirm should return the automatically selected time.

To Reproduce
Add example code that reproduces the behavior.

export default class App extends Component {

  state = { date: new Date() }

  render = () =>
    <DatePicker
      modal
      mode="time"
      androidVariant="nativeAndroid"
      minuteInterval={5}
      is24hourSource="locale"
      open={showTimePicker}
      date={selectedTime}
      minimumDate={minimumTime}
      onConfirm={(date) => onConfirmPick(date)}
    />

}

Smartphone (please complete the following information):

  • OS: Android
  • React Native version 0.72.5
  • react-native-date-picker version 4.3.3
@cosminpwd
Copy link
Author

Update: After removing minimumDate the problem still happens when switching between AM and PM (the new time is not saved on onConfirm).

@cosminpwd
Copy link
Author

Update: Switching between AM and PM works when pressing "Confirm" for a longer time, but does not get saved when tapping the button.

@owlfrancesco
Copy link

@cosminpwd I am having the same problem, I am using mode="date" .
Were you able to find a solution?

@rein96
Copy link

rein96 commented Jan 30, 2024

heyy I also encounter problem with enabling minimumDate prop

The calendar UI is automatically corrected based on minimumDate, but the date value from onDateChange prop does not send a new value

Version:
OS: Android
"react-native": "0.72.9"
"react-native-date-picker": "4.3.5"

@cosminpwd
Copy link
Author

No solution yet @owlfrancesco.

@owlfrancesco
Copy link

@cosminpwd @rein96 thanks.
I can confirm the problem only occurs on android, iOS works as expected.

OS: Android 13
"react-native": "0.72.4"
"react-native-date-picker": "^4.3.5"

@rein96
Copy link

rein96 commented Jan 31, 2024

hi @cosminpwd @owlfrancesco

good news I tested on version 4.2.10, date value from onDateChange works well based on minimumDate (tested on Android)

I think we need to figure it out what changes after 4.2.10 that might impact the logic

probably this one (but still not sure):
fix(android): min/max dates not always correct when timezoneOffsetInMinutes is set by @henninghall in #635

but for a quick fix, we can downgrade to 4.2.10 (I haven't tested 4.2.11 and so subsequent version)

@yfyau
Copy link
Contributor

yfyau commented Feb 6, 2024

@rein96 @owlfrancesco @cosminpwd
Hey folks, I believe the issue might be related to the fix I just created: #760
As a workaround, you may want to try removing the seconds part from minimumDate on your end.

@henninghall
Copy link
Owner

Thanks @yfyau, I will take a look at it!

@henninghall
Copy link
Owner

@yfyau's fix is released in version 4.3.6. Please check it out and if your original issue still exists @cosminpwd we can take another look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants