Skip to content

Commit

Permalink
fix go-to date
Browse files Browse the repository at this point in the history
setting the week-day here was once necessary when Etar was still using `android.text.format.Time`, where the days where 0-indexed (`java.util.Calendar`s days are 1-indexed).

doing this with `com.android.calendarcommon2.Time` is wrong, and will result in sundays being one week ahead.

additionally, setting the `DAY_OF_WEEK` without updating the `WEEK_OF_MONTH` will result in the old value of `WEEK_OF_MONTH` being used, as `Calendar` expects these to be set in combination when doing the computation: https://github.com/openjdk-mirror/jdk7u-jdk/blob/f4d80957e89a19a29bb9f9807d2a28351ed7f7df/src/share/classes/java/util/Calendar.java#L1729-L1740
  • Loading branch information
jonas-haeusler authored and Gitsaibot committed Jun 10, 2024
1 parent 190fb0d commit 852dfc6
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions app/src/main/java/com/android/calendar/AllInOneActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,6 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth
selectedTime.setMonth(monthOfYear);
selectedTime.setDay(dayOfMonth);

Calendar c = Calendar.getInstance();
c.set(year, monthOfYear, dayOfMonth);
int weekday = c.get(Calendar.DAY_OF_WEEK);
if (weekday == 1) {
selectedTime.setWeekDay(7);
} else {
selectedTime.setWeekDay(weekday - 1);
}

long extras = CalendarController.EXTRA_GOTO_TIME | CalendarController.EXTRA_GOTO_DATE;
mController.sendEvent(this, EventType.GO_TO, selectedTime, null, selectedTime, -1, ViewType.CURRENT, extras, null, null);
}
Expand Down

0 comments on commit 852dfc6

Please sign in to comment.