Browse Source

Fixed #8315 - take leap years into account in focusNext/PreviousYear

svn changeset:22857/svn branch:6.7
tags/7.0.0.alpha2
Johannes Dahlström 12 years ago
parent
commit
59e55e40b2
1 changed files with 16 additions and 1 deletions
  1. 16
    1
      src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java

+ 16
- 1
src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java View File

@@ -626,8 +626,15 @@ public class VCalendarPanel extends FocusableFlexTable implements
* Selects the previous year
*/
private void focusPreviousYear(int years) {
int currentMonth = focusedDate.getMonth();
focusedDate.setYear(focusedDate.getYear() - years);
displayedMonth.setYear(displayedMonth.getYear() - years);
/*
* If the focused date was a leap day (Feb 29), the new date becomes Mar
* 1 if the new year is not also a leap year. Set it to Feb 28 instead.
*/
if (focusedDate.getMonth() != currentMonth) {
focusedDate.setDate(0);
}
renderCalendar();
}

@@ -635,8 +642,16 @@ public class VCalendarPanel extends FocusableFlexTable implements
* Selects the next year
*/
private void focusNextYear(int years) {
int currentMonth = focusedDate.getMonth();
focusedDate.setYear(focusedDate.getYear() + years);
displayedMonth.setYear(displayedMonth.getYear() + years);
/*
* If the focused date was a leap day (Feb 29), the new date becomes Mar
* 1 if the new year is not also a leap year. Set it to Feb 28 instead.
*/
if (focusedDate.getMonth() != currentMonth) {
focusedDate.setDate(0);
}
renderCalendar();
}


Loading…
Cancel
Save