Skip to content

[Android] timeZoneOffsetInMinutes issue with minimumDate/maximumDate #518

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

Closed
PaitoAnderson opened this issue Oct 6, 2021 · 1 comment · Fixed by #519
Closed

[Android] timeZoneOffsetInMinutes issue with minimumDate/maximumDate #518

PaitoAnderson opened this issue Oct 6, 2021 · 1 comment · Fixed by #519
Labels

Comments

@PaitoAnderson
Copy link
Contributor

PaitoAnderson commented Oct 6, 2021

Bug report

Summary

When setting a minimum and maximum UTC date and setting timeZoneOffsetInMinutes={0} the Android picker is off by one day, I'm guessing it's using the device timezone somewhere.

Reproducible sample code

Using the example project, change these lines:

const [minDate, setMaxDate] = useState(new Date(Date.UTC(2021, 9, 2)));
const [maxDate, setMinDate] = useState(new Date(Date.UTC(2021, 9, 4)));

And also specify this for the <DateTimePicker />:

minimumDate={minDate}
maximumDate={maxDate}

(iOS Left: No issues, Android Right: Issue)
Screen Shot 2021-10-06 at 9 23 14 AM

Steps to reproduce

  1. Click Show Picker

Describe what you expected to happen:

  1. Should only let the user pick 2,3,4 instead, it let me pick 1,2,3 on Android.

Environment info

npx react-native info output:

System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.25 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.14.0 - ~/Development/datetimepicker/node_modules/.bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: Arctic Fox 2020.3.1 Patch 2 Arctic Fox 2020.3.1 Patch 2
    Xcode: 13.0/13A233 - /usr/bin/xcodebuild
  Languages:
    Java: 12.0.2 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: ^0.62.2 => 0.62.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

datetimepicker version: 3.5.2

iOS / Android version: iOS 15.0 / Android 10

vonovak added a commit that referenced this issue Dec 19, 2021
…ZoneOffsetInMinutes (#519)

* Fixes #518

* Add setTimeZone

* Revert setting end of day

* Add toggleMinMaxDate

* Better Demo

* Add E2E test for min/max

* Fix Android test

* Update android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java

Co-authored-by: Vojtech Novak <[email protected]>

* Update example/App.js

Co-authored-by: Vojtech Novak <[email protected]>

* More consistency

* Fix ESLint error

Co-authored-by: Vojtech Novak <[email protected]>
vonovak pushed a commit that referenced this issue Dec 19, 2021
## [5.0.2](v5.0.1...v5.0.2) (2021-12-19)

### Bug Fixes

* (android) fix issue with minimumDate/maximumDate when using timeZoneOffsetInMinutes ([#519](#519)) ([bdf6179](bdf6179)), closes [#518](#518)
@vonovak
Copy link
Member

vonovak commented Dec 19, 2021

🎉 This issue has been resolved in version 5.0.2 🎉

If this package helps you, consider sponsoring us! 🚀

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

Successfully merging a pull request may close this issue.

2 participants