woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

Fix date range picker issues with TimeZone #12887

Closed hichamboushaba closed 2 weeks ago

hichamboushaba commented 2 weeks ago

Closes: #12885

Description

This PR fixes an issue with the MaterialDatePicker, as stated in the ticket above, the component is buggy, it uses UTC internally, so when we get the result from it (as epoch time), it ends up shifted depending on the device timezone.

The fix is to shift the time to UTC before passing it to the date picker, then shift it back to the device timezone when we get the picked date.

Steps to reproduce

  1. Set you phone to a US timezone (for example NewYork)
  2. Open the app and make sure the performance card is added.
  3. Select a custom range.
  4. Confirm the dates shown in the card matches the picked dates in the picker.

The tests that have been performed

Images/gif

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

dangermattic commented 2 weeks ago
1 Warning
:warning: This PR is assigned to the milestone 21.1. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by :no_entry_sign: Danger

wpmobilebot commented 2 weeks ago
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit196def222c31f33b67abd3e5d5098a28182a9f9b
Direct Downloadwoocommerce-wear-prototype-build-pr12887-196def2.apk
wpmobilebot commented 2 weeks ago

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit196def222c31f33b67abd3e5d5098a28182a9f9b
Direct Downloadwoocommerce-prototype-build-pr12887-196def2.apk
codecov-commenter commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 40.20%. Comparing base (fc0c7e6) to head (196def2). Report is 5 commits behind head on trunk.

Files with missing lines Patch % Lines
.../com/woocommerce/android/extensions/FragmentExt.kt 0.00% 19 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## trunk #12887 +/- ## ============================================ - Coverage 40.21% 40.20% -0.01% + Complexity 5788 5787 -1 ============================================ Files 1251 1251 Lines 71261 71269 +8 Branches 9955 9956 +1 ============================================ - Hits 28660 28657 -3 - Misses 39966 39976 +10 - Partials 2635 2636 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.