aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-02-02 13:51:11 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-02-02 13:51:11 +0000
commit59e55e40b222cf06454f0bb936d26a9936a37913 (patch)
tree7816494601f3e2375fd26cbbbcbde1fdcd9ea092 /src/com
parentec6dccbfd4fcda327cb0b679fc551e1b5b2e3469 (diff)
downloadvaadin-framework-59e55e40b222cf06454f0bb936d26a9936a37913.tar.gz
vaadin-framework-59e55e40b222cf06454f0bb936d26a9936a37913.zip
Fixed #8315 - take leap years into account in focusNext/PreviousYear
svn changeset:22857/svn branch:6.7
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
index 0f45e7185b..96ca818bb4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
@@ -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();
}