1
0
mirror of https://github.com/moparisthebest/rcrdit synced 2024-12-22 07:18:56 -05:00

Make sure our guide data always contains all programs that end since the "Top of the hour"

This commit is contained in:
Jeff Lamb 2017-03-06 19:44:23 -05:00
parent 3c23769504
commit ad24fcc8a3
2 changed files with 15 additions and 4 deletions

View File

@ -43,9 +43,17 @@ public class Channel {
this.displayNames = fromChannel.displayNames;
this.id = fromChannel.id;
List<Program> programsForNewChannel = new ArrayList<>();
fromChannel.getPrograms().stream().filter((program) -> ((program.getStop().isAfter(startTime) && program.getStop().isBefore(stopTime)) || (program.getStart().isBefore(stopTime) && program.getStart().isAfter(startTime) )|| (program.getStart().isBefore(startTime) && program.getStop().isAfter(stopTime) ) || program.getStart().equals(startTime) || program.getStop().equals(stopTime) )).forEach((program) -> {
programsForNewChannel.add(program);
fromChannel.getPrograms().stream().forEach((program) -> {
boolean startsDuringDisplayTime = program.getStart().isAfter(startTime) && program.getStart().isBefore(stopTime);
boolean endsDuringDisplayTime = program.getStop().isAfter(startTime) && program.getStop().isBefore(stopTime);
boolean stopsAtStopTime = program.getStop().equals(stopTime);
boolean startsAtStartTime = program.getStart().equals(startTime);
boolean startsBeforeStartTimeAndEndsAfterEndTime = program.getStart().isBefore(startTime) && program.getStop().isAfter(stopTime);
if (startsDuringDisplayTime || endsDuringDisplayTime || stopsAtStopTime || startsAtStartTime || startsBeforeStartTimeAndEndsAfterEndTime) {
programsForNewChannel.add(program);
}
});
this.programs.addAll(programsForNewChannel);
}

View File

@ -22,7 +22,9 @@ import com.moparisthebest.sxf4j.impl.AbstractXmlElement;
import com.moparisthebest.sxf4j.impl.XmlElement;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.ResolverStyle;
@ -126,8 +128,9 @@ public class Tv {
break;
}
}
final Instant now = Instant.now().truncatedTo(ChronoUnit.MINUTES);
final LocalDateTime topOfHour = LocalDateTime.now().withMinute(0);
final Instant now = topOfHour.toInstant(ZoneOffset.systemDefault().getRules().getOffset(topOfHour)).truncatedTo(ChronoUnit.MINUTES);
//final Instant now = Instant.now()..truncatedTo(ChronoUnit.MINUTES);
for (final XmlElement prog : tv.getChildren("programme")) {
final String chanId = prog.getAttribute("channel");
final Channel channel = chanIdToChannel.get(chanId);