fix timezone offset issue in custom rpc timestamp picker#480
Open
rootdevss wants to merge 1 commit intodead8309:masterfrom
Open
fix timezone offset issue in custom rpc timestamp picker#480rootdevss wants to merge 1 commit intodead8309:masterfrom
rootdevss wants to merge 1 commit intodead8309:masterfrom
Conversation
Author
|
@dead8309 could you review this when you get a chance? |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a timezone-related date shift when converting the Material3 DatePicker selection into an epoch timestamp for Custom RPC timestamps, preventing “playing for 24 hours” caused by selecting the “current” day in negative UTC offsets.
Changes:
- Interpret
selectedDateMillisusing a UTCCalendarto extract stable Y/M/D components. - Construct a new local-time
Calendarusing those UTC-derived date components plus the user-selected time.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
hey, i noticed theres an issue with the custom rpc timestamp picker where selecting the current date causes discord to show "playing for 24 hours" instead of the correct time, to get the right timestamp users have to select the next day which is obviously not ideal
i looked into the code and found that the problem is in the getDateTimeInMillis function in DateTimePicker.kt, the datepicker returns timestamps in utc at midnight but when calendar.getinstance processes this value with the local timezone it shifts the date by one day for users in negative utc offsets like gmt-3
this pr changes the function to properly extract the date components from the utc timestamp and then create a new calendar instance in the local timezone with those values plus the user selected time, this should prevent the date shifting issue
i havent tested this myself since i dont have a test environment set up right now but the logic should fix the timezone conversion problem, would appreciate if you could review this and test it out.
thanks.