You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2019/07/22 13:12:18 UTC

[wicket] branch master updated: WICKET-6689 fix ClientProperties.getTimezone() UTC-DST differenc… (#377)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/master by this push:
     new 4851d3f  WICKET-6689 fix ClientProperties.getTimezone() UTC-DST differenc… (#377)
4851d3f is described below

commit 4851d3fda62ec84e636528bb75564b1d5c338532
Author: Mansour Rahimi <ra...@gmail.com>
AuthorDate: Mon Jul 22 15:12:13 2019 +0200

    WICKET-6689 fix ClientProperties.getTimezone() UTC-DST differenc… (#377)
    
    calculation.
---
 .../org/apache/wicket/protocol/http/ClientProperties.java   |  4 ++--
 .../apache/wicket/protocol/http/ClientPropertiesTest.java   | 13 +++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
index 2c2550d..ff200a1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
@@ -285,8 +285,8 @@ public class ClientProperties implements IClusterable
 					if (dstTimeZone != null &&
 						dstTimeZone.getRawOffset() != timeZone.getRawOffset())
 					{
-						int dstSaving = dstTimeZone.getRawOffset() - timeZone.getRawOffset();
-						String[] availableIDs = TimeZone.getAvailableIDs(timeZone.getRawOffset());
+						int dstSaving = Math.abs(dstTimeZone.getRawOffset() - timeZone.getRawOffset());
+						String[] availableIDs = TimeZone.getAvailableIDs(dstTimeZone.getRawOffset() < timeZone.getRawOffset() ? dstTimeZone.getRawOffset() : timeZone.getRawOffset());
 						for (String availableID : availableIDs)
 						{
 							TimeZone zone = TimeZone.getTimeZone(availableID);
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
index aeb69dc..f42785b 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
@@ -136,4 +136,17 @@ class ClientPropertiesTest
 
 		assertTrue(props.toString().contains("browserHeight=666"));
 	}
+
+	/**
+	 * WICKET-6689.
+	 */
+	@Test
+	void timezoneAET()
+	{
+		ClientProperties props = new ClientProperties();
+		props.setUtcOffset("11");
+		props.setUtcDSTOffset("10");
+
+		assertEquals(TimeZone.getTimeZone("AET"), props.getTimeZone());
+	}
 }