Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c0984a7 authored by Neil Fuller's avatar Neil Fuller
Browse files

Fix incorrect leap year logic

Fixing an issue for 2100 in SimpleMonthView.

Tweak the logic in DatePickerCalendarDelegate to optimize
for the common case and save a calculation.

Bug: 28784177
Test: build only
Change-Id: I7395ab9f3dc90ac4f7cef1edee6f7bc156f4ab76
parent ca13216b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -597,7 +597,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
            case Calendar.NOVEMBER:
            case Calendar.NOVEMBER:
                return 30;
                return 30;
            case Calendar.FEBRUARY:
            case Calendar.FEBRUARY:
                return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? 29 : 28;
                return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28;
            default:
            default:
                throw new IllegalArgumentException("Invalid Month");
                throw new IllegalArgumentException("Invalid Month");
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -850,7 +850,7 @@ class SimpleMonthView extends View {
            case Calendar.NOVEMBER:
            case Calendar.NOVEMBER:
                return 30;
                return 30;
            case Calendar.FEBRUARY:
            case Calendar.FEBRUARY:
                return (year % 4 == 0) ? 29 : 28;
                return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28;
            default:
            default:
                throw new IllegalArgumentException("Invalid Month");
                throw new IllegalArgumentException("Invalid Month");
        }
        }