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

Incorrect maximumDate cutoff on Android when timeZoneOffsetInMinutes is used #613

Closed
trooperandz opened this issue Feb 20, 2023 · 2 comments · Fixed by #635
Closed

Incorrect maximumDate cutoff on Android when timeZoneOffsetInMinutes is used #613

trooperandz opened this issue Feb 20, 2023 · 2 comments · Fixed by #635

Comments

@trooperandz
Copy link

Describe the bug
Android issue only: When a minimumDate and a maximumDate range of 24 or 48 hours is passed in, and a timeZoneOffsetInMinutes is also passed in, the datetime picker does not show the correct max cutoff time available on Android. When timeZoneOffsetInMinutes is removed, the datetime picker correctly reflects the date range.

Note: The datetime picker worked correctly on an older Android device, with OS Android 9.

For instance:

  • A date range of 24 hours (2/20 - 2/21) allows me to go from 2/20 4am up to 2/21 11:59pm (should be approximately 2/21 3:59am).
  • A date range of 48 hours (2/20 - 2/22) allows me to go from 2/20 4am up to 2/21 11:59pm (should be approximately 2/22 3:59am).

Expected behavior
The datetime picker should correctly observe the provided minimumDate and maximumDate range on Android devices when timeZoneOffsetInMinutes is passed in.

To Reproduce

const [date, setDate] = React.useState(new Date());

<DatePicker
  androidVariant="nativeAndroid"
  date={date}
  is24hourSource="locale"
  minimumDate={new Date("2023-02-20T11:00:00.000Z")}
  maximumDate={new Date("2023-02-22T10:00:00.000Z")}
  onDateChange={setDate}
  timeZoneOffsetInMinutes={-420}
/>;

Smartphone (please complete the following information):

  • OS: Android Samsung s21 13.0, Android emulator 11.0 API R, Android emulator 12.0 API 31.
  • React Native version 0.70.6
  • react-native-date-picker version 4.2.5

Demo with incorrect 48 hour range, including timeZoneOffsetInMinutes

android-datetimepicker

Demo with correct 48-hour range, excluding timeZoneOffsetInMinutes

android-datetimepicker-no-offset

@randhi-w
Copy link

randhi-w commented Apr 7, 2023

Im having the same issue too but only when we pass today as the maximumDate with timeZoneOffsetInMinutes when the mode of the date picker is 'dateTime'. The date picker renders dates 6 months ahead

@henninghall
Copy link
Owner

Thanks for reporting this together with a great explanation of the problem @trooperandz. A fix for this is released in version 4.2.11.

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