WeekDatePicker icon indicating copy to clipboard operation
WeekDatePicker copied to clipboard

not expected result on selectDay(LocalDate date)

Open haoziliu opened this issue 8 years ago • 0 comments

    private int getDayForDate(@NonNull LocalDate date) {
        return firstDay.until(date).getDays();
    }

This method is supposed to get the offset of days from first day. But in fact it only get the days of month. As a result, selectDay and setDateIndicator won't work correctly.

This would be correct:

    private int getDayForDate(@NonNull LocalDate date) {
        return (int) (date.toEpochDay() - firstDay.toEpochDay());
    }

or

    private int getDayForDate(@NonNull LocalDate date) {
        return (int) firstDay.until(date, ChronoUnit.DAYS);
    }

haoziliu avatar Oct 11 '17 17:10 haoziliu