[libpostgresql-jdbc-java] 07/08: Fix time tests for timezones which have different rules now than at the unix epoch. We need to pull the zone offset for the time value we're manipulating rather than the current time. "Europe/London" is the failing example, but there may be more.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:20:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_2_510
in repository libpostgresql-jdbc-java.

commit c3a46f2f46b68f84fa35f8f35dd3795dd99a06a6
Author: Kris Jurka <books at ejurka.com>
Date:   Thu May 28 21:27:02 2009 +0000

    Fix time tests for timezones which have different rules now than
    at the unix epoch.  We need to pull the zone offset for the time
    value we're manipulating rather than the current time.
    "Europe/London" is the failing example, but there may be more.
    
    John Lister
---
 org/postgresql/test/jdbc2/TimeTest.java | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/org/postgresql/test/jdbc2/TimeTest.java b/org/postgresql/test/jdbc2/TimeTest.java
index 0bc2530..e4bfd51 100644
--- a/org/postgresql/test/jdbc2/TimeTest.java
+++ b/org/postgresql/test/jdbc2/TimeTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/TimeTest.java,v 1.16 2005/01/11 08:25:48 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/TimeTest.java,v 1.17 2005/08/01 06:54:15 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -59,9 +59,9 @@ public class TimeTest extends TestCase
 
         cal.setTimeZone(TimeZone.getTimeZone("GMT"));
 
-        long localOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET);
+        int localOffset=Calendar.getInstance().getTimeZone().getOffset(midnight.getTime());
 
-        /* set the time to midnight to make this easy */
+        // set the time to midnight to make this easy
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "'00:00:00','00:00:00'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "'00:00:00.1','00:00:00.01'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "CAST(CAST(now() AS timestamp without time zone) AS time),now()")));
@@ -265,11 +265,7 @@ public class TimeTest extends TestCase
             t = rs.getTime(1);
             assertNotNull(t);
             java.sql.Time tmpTime = java.sql.Time.valueOf("5:1:2");
-            int localoffset = java.util.Calendar.getInstance().getTimeZone().getRawOffset();
-            if (java.util.Calendar.getInstance().getTimeZone().inDaylightTime(tmpTime))
-            {
-                localoffset += 60 * 60 * 1000;
-            }
+            int localoffset=java.util.Calendar.getInstance().getTimeZone().getOffset(tmpTime.getTime());
             int Timeoffset = 3 * 60 * 60 * 1000;
             tmpTime.setTime(tmpTime.getTime() + Timeoffset + localoffset);
             assertEquals(makeTime(tmpTime.getHours(), tmpTime.getMinutes(), tmpTime.getSeconds()), t);
@@ -278,11 +274,7 @@ public class TimeTest extends TestCase
             t = rs.getTime(1);
             assertNotNull(t);
             tmpTime = java.sql.Time.valueOf("23:59:59");
-            localoffset = java.util.Calendar.getInstance().getTimeZone().getRawOffset();
-            if (java.util.Calendar.getInstance().getTimeZone().inDaylightTime(tmpTime))
-            {
-                localoffset += 60 * 60 * 1000;
-            }
+            localoffset=java.util.Calendar.getInstance().getTimeZone().getOffset(tmpTime.getTime());
             Timeoffset = -11 * 60 * 60 * 1000;
             tmpTime.setTime(tmpTime.getTime() + Timeoffset + localoffset);
             assertEquals(makeTime(tmpTime.getHours(), tmpTime.getMinutes(), tmpTime.getSeconds()), t);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list