Skip to content

[Android] Fix issue with minimumDate/maximumDate when using timeZoneOffsetInMinutes #519

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

Merged
merged 12 commits into from
Dec 19, 2021

Conversation

PaitoAnderson
Copy link
Contributor

@PaitoAnderson PaitoAnderson commented Oct 8, 2021

Fixes #518

Summary

On Android setMinDate and setMaxDate assumes the datetime passed will be in the device's local timezone, we now account for this by subtracting the minimumDate/maximumDate datetime offsets and also the provided timeZoneOffsetInMinutes.

Test Plan

I've added a toggleMinMaxDate button in the demo project that shows this feature using two UTC min/max dates. Here is the before/after in -4 GMT.

Before:
Screenshot_1633700803
After:
Screenshot_1633700838

What's required for testing (prerequisites)?

Test using the toggleMinMaxDate button in the demo project.

FYI - I was unable to find a good way to pick a date using detox for e2e tests on Android.

What are the steps to reproduce (after prerequisites)?

Using any negative timezone on the device should show this issue in the demo project.

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)
  • I added a sample use of the API in the example project (example/App.js)
  • I have added automated tests, either in JS or e2e tests, as applicable

Copy link
Member

@vonovak vonovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello and thank you for the PR!

I have added some small comments. Also, I'd really appreciate if you could add some e2e tests for this so that we know the android and ios behavior is the same, since the tz offset on android is not working 100%.

Selecting dates on android is kinda pain, the best way I know is in this PR: //github.com/react-native-datetimepicker/datetimepicker/pull/new/fix/use-resource-ids

Also, can you please rebase on master?

thank you for your time! :)

@PaitoAnderson
Copy link
Contributor Author

Thanks for reviewing and pointing me in the right direction on the android date picker selection for the e2e test.

Copy link
Member

@vonovak vonovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello and thanks so much, I'd like to ask for a few more small changes and then we're good to merge! :)

thanks

@PaitoAnderson
Copy link
Contributor Author

Thank you for reviewing! Let me know if you want anything else :)

@vonovak vonovak merged commit bdf6179 into react-native-datetimepicker:master Dec 19, 2021
vonovak pushed a commit that referenced this pull request 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 this pull request may close these issues.

[Android] timeZoneOffsetInMinutes issue with minimumDate/maximumDate
2 participants