From 9c51ceaa9b56ab1d6e30af3ff32786fea5dc8586 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 14 Sep 2010 12:24:47 +0000 Subject: [PATCH] Actual fix for #5594 svn changeset:14908/svn branch:6.4 --- .../terminal/gwt/client/ui/VCalendarPanel.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java index df50ca0391..c97f360d53 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java @@ -259,16 +259,27 @@ public class VCalendarPanel extends FocusableFlexTable implements private void selectFocused() { if (focusedDate != null) { int changedFields = 0; + /* + * #5594 set Date (day) to 1 in order to prevent any kind of + * wrapping of months when later setting the month. (e.g. 31 -> + * month with 30 days -> wraps to the 1st of the following month, + * e.g. 31st of May -> 31st of April = 1st of May) + */ + value.setDate(1); if (value.getYear() != focusedDate.getYear()) { + value.setYear(focusedDate.getYear()); changedFields += VDateField.RESOLUTION_YEAR; } if (value.getMonth() != focusedDate.getMonth()) { + value.setMonth(focusedDate.getMonth()); changedFields += VDateField.RESOLUTION_MONTH; } if (value.getDate() != focusedDate.getDate()) { changedFields += VDateField.RESOLUTION_DAY; } - value.setTime(focusedDate.getTime()); + // We always need to set the date, even if it hasn't changed, since + // it was forced to 1 above. + value.setDate(focusedDate.getDate()); selectDate(focusedDate.getDate()); } else { -- 2.39.5