test/java/time/tck/java/time/zone/TCKZoneRules.java

Print this page

        

*** 57,69 **** * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tck.java.time.zone; - import java.time.temporal.Year; - import java.time.zone.*; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; --- 57,66 ----
*** 79,92 **** --- 76,93 ---- import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; + import java.time.Year; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; + import java.time.zone.ZoneOffsetTransition; + import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; + import java.time.zone.ZoneRules; import org.testng.annotations.Test; /** * Test ZoneRules.
*** 140,150 **** ZoneRules test = europeLondon(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, -1, -15); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.getDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); } --- 141,151 ---- ZoneRules test = europeLondon(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, -1, -15); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.toLocalDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); }
*** 520,530 **** ZoneRules test = europeParis(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.getDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); } --- 521,531 ---- ZoneRules test = europeParis(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.toLocalDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); }
*** 670,686 **** public void test_Paris_getStandardOffset() { ZoneRules test = europeParis(); ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC); while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); ! if (zdt.getDate().isBefore(LocalDate.of(1911, 3, 11))) { assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21)); ! } else if (zdt.getDate().isBefore(LocalDate.of(1940, 6, 14))) { assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); ! } else if (zdt.getDate().isBefore(LocalDate.of(1944, 8, 25))) { assertEquals(test.getStandardOffset(instant), OFFSET_PONE); ! } else if (zdt.getDate().isBefore(LocalDate.of(1945, 9, 16))) { assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); } else { assertEquals(test.getStandardOffset(instant), OFFSET_PONE); } zdt = zdt.plusMonths(6); --- 671,687 ---- public void test_Paris_getStandardOffset() { ZoneRules test = europeParis(); ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC); while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); ! if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) { assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21)); ! } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) { assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); ! } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) { assertEquals(test.getStandardOffset(instant), OFFSET_PONE); ! } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) { assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); } else { assertEquals(test.getStandardOffset(instant), OFFSET_PONE); } zdt = zdt.plusMonths(6);
*** 703,713 **** ZoneRules test = americaNewYork(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.of("-04:56:02"); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.getDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); } --- 704,714 ---- ZoneRules test = americaNewYork(); ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.of("-04:56:02"); assertEquals(test.getOffset(instant), offset); ! checkOffset(test, old.toLocalDateTime(), offset, 1); assertEquals(test.getStandardOffset(instant), offset); assertEquals(test.getDaylightSavings(instant), Duration.ZERO); assertEquals(test.isDaylightSavings(instant), false); }
*** 876,886 **** public void test_NewYork_getStandardOffset() { ZoneRules test = americaNewYork(); ZonedDateTime dateTime = createZDT(1860, 1, 1, ZoneOffset.UTC); while (dateTime.getYear() < 2010) { Instant instant = dateTime.toInstant(); ! if (dateTime.getDate().isBefore(LocalDate.of(1883, 11, 18))) { assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02")); } else { assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5)); } dateTime = dateTime.plusMonths(6); --- 877,887 ---- public void test_NewYork_getStandardOffset() { ZoneRules test = americaNewYork(); ZonedDateTime dateTime = createZDT(1860, 1, 1, ZoneOffset.UTC); while (dateTime.getYear() < 2010) { Instant instant = dateTime.toInstant(); ! if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) { assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02")); } else { assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5)); } dateTime = dateTime.plusMonths(6);