Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdJuX-0001hx-5K for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Jun 2019 19:36:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdJuV-0000VO-VM for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Jun 2019 19:36:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdJuV-0000VH-J9 for pgsql-jdbc@lists.postgresql.org; Tue, 18 Jun 2019 19:36:51 +0000 Received: from out-2.smtp.github.com ([192.30.252.193]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdJuT-0007ys-5V for pgsql-jdbc@lists.postgresql.org; Tue, 18 Jun 2019 19:36:50 +0000 Date: Tue, 18 Jun 2019 12:36:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1560886608; bh=4kHuVBWx2dzkCswloSoSmY58rdosZUefqApj0TW7Z9s=; h=Date:From:To:Subject:From; b=Yi1le0h0qLnIc7ZuNGpHbkJVBIvSc7wMQ8j7oTqYfm6rOHdPQn7jK2AsEVo6DR3HG 8HkHjlqXkRC/KWOqsO36lxshzloyqBqhIKA096VP7oT5UCEKPgocop2VbMb8C9nA4k dRGoFGdGyMlCfX5vl6GGrZt1qtpBcCVaW5MWDkCc= From: Vladimir Sitnikov To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] b56538: fix: date rounding errors for dates before 1970 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: b565389920f78702625ee263473bd9b3ec97f764 https://github.com/pgjdbc/pgjdbc/commit/b565389920f78702625ee263473bd9b3ec97f764 Author: Vladimir Sitnikov Date: 2019-06-18 (Tue, 18 Jun 2019) Changed paths: M pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimestampTest.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimezoneTest.java M pgjdbc/src/test/java/org/postgresql/test/jdbc42/GetObject310Test.java M pgjdbc/src/test/java/org/postgresql/test/jdbc42/SetObject310Test.java Log Message: ----------- fix: date rounding errors for dates before 1970 millis % ONEDAY should be reworked to floorMod(millis, ONEDAY) Regular division "rounds" towards zero, however that is not what we want for dates Division "towards zero" results to adding a day for dates with "negative" long values. So we should use floorDiv/floorMod to get date/time components see #1499