summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/DateTimeService.java6
-rwxr-xr-xclient/tests/src/com/vaadin/client/DateTimeServiceTest.java10
2 files changed, 15 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/DateTimeService.java b/client/src/com/vaadin/client/DateTimeService.java
index bf57261c72..f4cfe7a278 100644
--- a/client/src/com/vaadin/client/DateTimeService.java
+++ b/client/src/com/vaadin/client/DateTimeService.java
@@ -281,7 +281,11 @@ public class DateTimeService {
Date firstOfJanuary = new Date(nearestThursday.getYear(), 0, 1);
long timeDiff = nearestThursday.getTime() - firstOfJanuary.getTime();
- int daysSinceFirstOfJanuary = (int) (timeDiff / MILLISECONDS_PER_DAY);
+
+ // Rounding the result, as the division doesn't result in an integer
+ // when the given date is inside daylight saving time period.
+ int daysSinceFirstOfJanuary = (int) Math.round((double) timeDiff
+ / MILLISECONDS_PER_DAY);
int weekNumber = (daysSinceFirstOfJanuary) / 7 + 1;
diff --git a/client/tests/src/com/vaadin/client/DateTimeServiceTest.java b/client/tests/src/com/vaadin/client/DateTimeServiceTest.java
index 3f4828678f..f9351d1cc0 100755
--- a/client/tests/src/com/vaadin/client/DateTimeServiceTest.java
+++ b/client/tests/src/com/vaadin/client/DateTimeServiceTest.java
@@ -48,6 +48,16 @@ public class DateTimeServiceTest extends TestCase {
isoWeekNumbers.put(getDate(2010, 1, 4), 1);
isoWeekNumbers.put(getDate(2010, 1, 5), 1);
isoWeekNumbers.put(getDate(2010, 10, 10), 40);
+ isoWeekNumbers.put(getDate(2015, 3, 24), 13);
+ isoWeekNumbers.put(getDate(2015, 3, 31), 14);
+ isoWeekNumbers.put(getDate(2015, 10, 13), 42);
+ isoWeekNumbers.put(getDate(2015, 10, 20), 43);
+ isoWeekNumbers.put(getDate(2015, 10, 27), 44);
+ isoWeekNumbers.put(getDate(2026, 3, 24), 13);
+ isoWeekNumbers.put(getDate(2026, 3, 31), 14);
+ isoWeekNumbers.put(getDate(2026, 10, 13), 42);
+ isoWeekNumbers.put(getDate(2026, 10, 20), 43);
+ isoWeekNumbers.put(getDate(2026, 10, 27), 44);
}