[pgjdbc/pgjdbc] b56538: fix: date rounding errors for dates before 1970

Vladimir Sitnikov <[email protected]> Tue, 18 Jun 2019 12:36:48 -0700
Newsgroups gmane.comp.db.postgresql.jdbc
Message-ID <pgjdbc/pgjdbc/push/refs/heads/master/[email protected]>
  Branch: refs/heads/master
  Home:   https://github.com/pgjdbc/pgjdbc
  Commit: b565389920f78702625ee263473bd9b3ec97f764
      https://github.com/pgjdbc/pgjdbc/commit/b565389920f78702625ee263473bd9b3ec97f764
  Author: Vladimir Sitnikov <[email protected]>
  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