|
@@ -28,6 +28,7 @@ import java.time.Instant;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.time.zone.ZoneOffsetTransition;
|
|
|
+import java.time.zone.ZoneRules;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -76,11 +77,10 @@ public class LocalTimeOffsetTests extends ESTestCase {
|
|
|
|
|
|
assertRoundingAtOffset(randomBoolean() ? fixed : fixedInRange, randomLong(), offsetMillis);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void assertRoundingAtOffset(LocalTimeOffset offset, long time, long offsetMillis) {
|
|
|
assertThat(offset.utcToLocalTime(time), equalTo(time + offsetMillis));
|
|
|
assertThat(offset.localToUtcInThisOffset(time + offsetMillis), equalTo(time));
|
|
|
- assertThat(offset.localToUtc(time + offsetMillis, unusedStrategy()), equalTo(time));
|
|
|
}
|
|
|
|
|
|
public void testJustTransitions() {
|
|
@@ -155,6 +155,26 @@ public class LocalTimeOffsetTests extends ESTestCase {
|
|
|
assertRoundingAtOffset(lookup.lookup(time), time, TimeUnit.MINUTES.toMillis(345));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * America/Tijuana's
|
|
|
+ * {@link ZoneRules#getTransitions() fully defined transitions} overlap
|
|
|
+ * with its {@link ZoneRules#getTransitionRules() future rules} and if
|
|
|
+ * we're not careful we can end up with duplicate transitions because we
|
|
|
+ * have to collect them independently. That will trip assertions, failing
|
|
|
+ * this test real fast. If they don't trip the assertions then trying to
|
|
|
+ * use the transitions will produce incorrect results, failing the
|
|
|
+ * size assertion.
|
|
|
+ */
|
|
|
+ public void testLastTransitionOverlapsRules() {
|
|
|
+ ZoneId zone = ZoneId.of("America/Tijuana");
|
|
|
+ long min = utcTime("2011-11-06T08:31:57.091Z");
|
|
|
+ long max = utcTime("2011-11-06T09:02:57.091Z");
|
|
|
+ LocalTimeOffset.Lookup lookup = LocalTimeOffset.lookup(zone, min, max);
|
|
|
+ assertThat(lookup.size(), equalTo(2));
|
|
|
+ assertRoundingAtOffset(lookup.lookup(min), min, -TimeUnit.HOURS.toMillis(7));
|
|
|
+ assertRoundingAtOffset(lookup.lookup(max), max, -TimeUnit.HOURS.toMillis(8));
|
|
|
+ }
|
|
|
+
|
|
|
public void testOverlap() {
|
|
|
/*
|
|
|
* Europe/Rome turn their clocks back an hour 1978 which is totally
|