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

Android DateTime picker bugs with minDate and maxDate #670

Closed
JoelJKoel opened this issue Jun 30, 2023 · 7 comments · Fixed by #740
Closed

Android DateTime picker bugs with minDate and maxDate #670

JoelJKoel opened this issue Jun 30, 2023 · 7 comments · Fixed by #740

Comments

@JoelJKoel
Copy link

Description of the bug
Found a series of bugs when trying to use date picker on Android with DateTime mode regarding the minDate and maxDate props.
Without specifying minDate value the maximum time user can go back is 6 months.
image
Current date was 30. June.

If I specify minDate value for example selectedDate - 1 year and dont set a maxDate then when opening the date picker the default value will be the minDate value and maximum time I could select was minDate + 6 months. So comparing to current date I could select a date between -1 year and -6 months.
image
image
minDate set as (selectedDate - 1 year), maxDate is undefined, tried to scroll to the furthest date in the future

If I specify minDate value for example selectedDate - 1 year and maxDate as current date it works as expected initially.
image
But once I select a different date in the past and reopen the picker (in this case current_date -23h57m) user can no longer select "Today" as a date.
image

The issue is that I cant leave minDate undefined since I want user to be able to select a date from a calendar and then select a time period in regards to that selected date. If minDate is undefined they cant go back further than 6 months. But if I leave minDate undefined I run into the wrong default value and stuck with the past dates issue. And if I do set maxDate so they cant select dates in the future then in some situations after editing the current value they cant select current date ("Today") anymore.

Expected behavior
Similar behavior to iOS, you can freely set minDate and maxDate value without it altering the usability of the datepicker.

Example code

<DatePicker
date={new Date(props.date)}
onDateChange={props.onChange}
style={styles.datePicker}
mode={'datetime'}
is24hourSource="locale"
fadeToColor="none"
minimumDate={props.minDate || null}
maximumDate={props.maxDate || null}
/>

Smartphone (please complete the following information):
OS: Android
React Native version 0.67.5
react-native-date-picker version 4.2.12

@JoelJKoel JoelJKoel changed the title Android DateTime picker bugs Android DateTime picker bugs with minDate and maxDate Jun 30, 2023
@JoelJKoel
Copy link
Author

For clarification the issue is not just "Today" date missing from picker selection, it can be any maxDate date value missing if the difference between minDate and maxDate is less than N days. For example minDate is set as 2023-06-26T09:14:00.000Z and maxDate is 2023-06-29T09:13:00.000Z as a result the 29 Jun selection is missing.
image
If I increase maxDate time to 9:14 the 29 Jun selection is there again.

@henninghall
Copy link
Owner

Hi, thanks for reporting this. What timezone is the simulator/phone using? Note that 2023-06-29T09:13:00.000Z is UTC and the visible time in the picker is in the local timezone by default.

@JoelJKoel
Copy link
Author

Hi! The simulator phone was using UTC+3 timezone.

@kaancembertas
Copy link

kaancembertas commented Jul 31, 2023

Hi, I am facing the same issue on android with minDate and maxDate

PS: reverting to version of 4.1.3 fixed the problem.

@IvanSantiagoUk
Copy link

Same issue on 4.3.3

Is there a plan to fix this on the near future?

@Ethan-G
Copy link

Ethan-G commented Dec 18, 2023

I found the date picker will display the number of days equal to max-min/24, rounded DOWN. So if minDate is 1 second from now, and max is 3 days from now, it will only show 2 days. If max is 3 days and 1 second from now, behaviour is as expected.

(All Android, iOS is fine it seems).

@henninghall
Copy link
Owner

Thanks for helping out understanding this bug. I managed to reproduce it and fix it by #740. It is released in version 4.3.5.

Please let me know if you still experience anything unexpected after upgrading to 4.3.5.

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