From b18fbe89490860e4d47c21166d7b38569f356f2d Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Mon, 9 Mar 2020 20:43:01 +0100 Subject: [PATCH] Work around the bug in ComposeScheduleView, fix #1720 (#1722) DatePicker seems to think that it's in UTC. So setting selected time might not work as aspect and receiving value from it might be in UTC as well. This commit fixes the second issue by interpreting the date as UTC date. Tested with America/New_York (GMT-5 at the moment) and Russia/Kamchatka (GMT+12). --- .../tusky/components/compose/view/ComposeScheduleView.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java index 0deb20be..ca663936 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java @@ -192,6 +192,9 @@ public class ComposeScheduleView extends ConstraintLayout { private void onDateSet(long selection) { initializeSuggestedTime(); Calendar newDate = getCalendar(); + // working around bug in DatePicker where date is UTC #1720 + // see https://github.com/material-components/material-components-android/issues/882 + newDate.setTimeZone(TimeZone.getTimeZone("UTC")); newDate.setTimeInMillis(selection); scheduleDateTime.set(newDate.get(Calendar.YEAR), newDate.get(Calendar.MONTH), newDate.get(Calendar.DATE)); openPickTimeDialog();