Repository navigation
fix(android): open material date picker on the value's day in the target timezone - #1078
Open
Tayyeb-max wants to merge 1 commit into
Open
Tayyeb-max wants to merge 1 commit into
Tayyeb-max wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1077
RNMaterialDatePickerpassed the rawvaluetimestamp toMaterialDatePicker.Builder.setSelection(). The Material picker reads the selection as a UTC day (SingleDateSelector.setSelection→UtcDates.canonicalYearMonthDay), so when the value falls on a different calendar day in UTC than in the target timezone, the picker opens on the wrong day: a day early for zones ahead of UTC near midnight, a day late for zones behind UTC late in the evening.The selection is now midnight UTC of the value's year, month and day in the target timezone (
timeZoneName,timeZoneOffsetInMinutesor the device zone, throughRNDate). This mirrors the conversioncreateNewCalendaralready does for the selection coming back from the picker. It follows the approach suggested in the issue.Test Plan
What's required for testing (prerequisites)?
Example app on an Android device or emulator in a timezone ahead of UTC, e.g. Asia/Karachi (UTC+5). Tested on a Pixel 7a, Android 17.
What are the steps to reproduce (after prerequisites)?
material, modetime: set the time to 02:00. The value is now 2021-11-13T02:00+05:00 (2021-11-12T21:00Z).date, input modedefault, press "Show picker!".The date math was also checked off-device for Europe/Brussels, Asia/Karachi, Asia/Kolkata, America/New_York and Pacific/Kiritimati (old selection on the wrong day in each) and UTC (unchanged).
Compatibility