@Test public void tuesdayToSaturdayTwoTimeFramesAreInTheSameDay00oClockLondonAnd00oClockOfTheNextDay() { final D1 cut = new D1(); for (int day = 17; day <= 20; day++) { assertThat(cut.areInSameTimeFrame( LocalDate.of(2014, Month.JUNE, day).atTime(0, 0, 0, 0).toInstant(ZoneOffset.ofHours(1)), LocalDate.of(2014, Month.JUNE, day).atTime(23, 59, 59, 99999).toInstant(ZoneOffset.ofHours(1)))) .isTrue(); assertThat(cut.areInSameTimeFrame( LocalDate.of(2014, Month.JUNE, day).atTime(15, 21, 35, 0).toInstant(ZoneOffset.ofHours(1)), LocalDate.of(2014, Month.JUNE, day).atTime(07, 10, 58, 5912).toInstant(ZoneOffset.ofHours(1)))) .isTrue(); } for (int day = 13; day <= 16; day++) { assertThat(cut.areInSameTimeFrame( LocalDate.of(2005, Month.DECEMBER, day).atTime(0, 0, 0, 0).toInstant(ZoneOffset.ofHours(0)), LocalDate.of(2005, Month.DECEMBER, day).atTime(23, 59, 59, 99999).toInstant(ZoneOffset.ofHours(0)))) .isTrue(); } assertThat(cut.areInSameTimeFrame( LocalDate.of(2014, Month.JUNE, 18).atTime(0, 5, 0, 0).toInstant(ZoneOffset.ofHours(1)), LocalDate.of(2014, Month.JUNE, 19).atTime(0, 5, 0, 0).toInstant(ZoneOffset.ofHours(1)))).isFalse(); assertThat(cut.areInSameTimeFrame( LocalDate.of(2013, Month.JUNE, 18).atTime(0, 0, 34, 0).toInstant(ZoneOffset.ofHours(1)), LocalDate.of(2014, Month.JUNE, 18).atTime(0, 0, 34, 0).toInstant(ZoneOffset.ofHours(1)))).isFalse(); }
@Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0); final ZonedDateTime start; final ZonedDateTime end; if (britishDay == SUNDAY) { if (britishTime.isBefore(localBase.withHour(22))) { start = localBase; end = localBase.withHour(22); } else { start = localBase.withHour(22); end = localBase.plusDays(2); } } else if (britishDay == MONDAY) { start = localBase.minusDays(1).withHour(22); end = localBase.plusDays(1); } else { start = localBase; end = localBase.plusDays(1); } return instant2.equals(start.toInstant()) || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant())); }
D1 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0); final ZonedDateTime start; final ZonedDateTime end; if (britishDay == SUNDAY) { if (britishTime.isBefore(localBase.withHour(22))) { start = localBase; end = localBase.withHour(22); } else { start = localBase.withHour(22); end = localBase.plusDays(2); } } else if (britishDay == MONDAY) { start = localBase.minusDays(1).withHour(22); end = localBase.plusDays(1); } else { start = localBase; end = localBase.plusDays(1); } return instant2.equals(start.toInstant()) || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant())); } }
D1 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0); final ZonedDateTime start; final ZonedDateTime end; if (britishDay == SUNDAY) { if (britishTime.isBefore(localBase.withHour(22))) { start = localBase; end = localBase.withHour(22); } else { start = localBase.withHour(22); end = localBase.plusDays(2); } } else if (britishDay == MONDAY) { start = localBase.minusDays(1).withHour(22); end = localBase.plusDays(1); } else { start = localBase; end = localBase.plusDays(1); } return instant2.equals(start.toInstant()) || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant())); }  }
D1 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0); final ZonedDateTime start; final ZonedDateTime end; if (britishDay == SUNDAY) { if (britishTime.isBefore(localBase.withHour(22))) { start = localBase; end = localBase.withHour(22); } else { start = localBase.withHour(22); end = localBase.plusDays(2); } } else if (britishDay == MONDAY) { start = localBase.minusDays(1).withHour(22); end = localBase.plusDays(1); } else { start = localBase; end = localBase.plusDays(1); } return instant2.equals(start.toInstant()) || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant())); }  @Override Instant instantOfNextFrame(final Instant instant); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2); }
D1 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0); final ZonedDateTime start; final ZonedDateTime end; if (britishDay == SUNDAY) { if (britishTime.isBefore(localBase.withHour(22))) { start = localBase; end = localBase.withHour(22); } else { start = localBase.withHour(22); end = localBase.plusDays(2); } } else if (britishDay == MONDAY) { start = localBase.minusDays(1).withHour(22); end = localBase.plusDays(1); } else { start = localBase; end = localBase.plusDays(1); } return instant2.equals(start.toInstant()) || (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant())); }  @Override Instant instantOfNextFrame(final Instant instant); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2);  }