private void doTest_factory_ofInstant_all(long minYear, long maxYear) {

    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int minOffset = (minYear <= 0 ? 0 : 3);
    int maxOffset = (maxYear <= 0 ? 0 : 3);
    long minDays = (minYear * 365L + ((minYear + minOffset) / 4L - (minYear + minOffset) / 100L + (minYear + minOffset) / 400L))
        - days_0000_to_1970;
    long maxDays = (maxYear * 365L + ((maxYear + maxOffset) / 4L - (maxYear + maxOffset) / 100L + (maxYear + maxOffset) / 400L))
        + 365L - days_0000_to_1970;

    final LocalDate maxDate = LocalDate.of(Year.MAX_YEAR, 12, 31);
    OffsetDateTime expected = OffsetDateTime.of((int) minYear, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
    for (long i = minDays; i < maxDays; i++) {
      Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L);
      try {
        OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC);
        assertEquals(test, expected);
        if (expected.getDate().equals(maxDate) == false) {
          expected = expected.plusDays(1);
        }
      } catch (RuntimeException | Error ex) {
        System.out.println("Error: " + i + " " + expected);
        throw ex;
      }
    }
  }

  // for performance testing
  // private void doTest_factory_ofInstant_all(int minYear, int maxYear) {
  // long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
  // int minOffset = (minYear <= 0 ? 0 : 3);
  // int maxOffset = (maxYear <= 0 ? 0 : 3);
  // long minDays = (long) (minYear * 365L + ((minYear + minOffset) / 4L - (minYear + minOffset) / 100L +
  // (minYear + minOffset) / 400L)) - days_0000_to_1970;
  // long maxDays = (long) (maxYear * 365L + ((maxYear + maxOffset) / 4L - (maxYear + maxOffset) / 100L +
  // (maxYear + maxOffset) / 400L)) + 365L - days_0000_to_1970;
  //
  // OffsetDateTime expected = OffsetDateTime.dateTime(minYear, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
  // Date cutover = new Date(Long.MIN_VALUE);
  // GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
  // cal.setGregorianChange(cutover);
  // for (long i = minDays; i < maxDays; i++) {
  // Instant instant = Instant.instant(i * 24L * 60L * 60L);
  // try {
  // cal.setTimeInMillis(instant.getEpochSecond() * 1000L);
  // assertEquals(cal.get(GregorianCalendar.MONTH), expected.getMonth().getValue() - 1);
  // assertEquals(cal.get(GregorianCalendar.DAY_OF_MONTH), expected.getDayOfMonth().getValue());
  // expected = expected.plusDays(1);
  // } catch (RuntimeException ex) {
  // System.out.println("Error: " + i + " " + expected);
  // throw ex;
  // } catch (Error ex) {
  // System.out.println("Error: " + i + " " + expected);
  // throw ex;
  // }
  // }
  // }