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:
parent
3c23769504
commit
ad24fcc8a3
@ -43,9 +43,17 @@ public class Channel {
|
|||||||
this.displayNames = fromChannel.displayNames;
|
this.displayNames = fromChannel.displayNames;
|
||||||
this.id = fromChannel.id;
|
this.id = fromChannel.id;
|
||||||
List<Program> programsForNewChannel = new ArrayList<>();
|
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) -> {
|
fromChannel.getPrograms().stream().forEach((program) -> {
|
||||||
programsForNewChannel.add(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);
|
this.programs.addAll(programsForNewChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@ import com.moparisthebest.sxf4j.impl.AbstractXmlElement;
|
|||||||
import com.moparisthebest.sxf4j.impl.XmlElement;
|
import com.moparisthebest.sxf4j.impl.XmlElement;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
import java.time.format.ResolverStyle;
|
import java.time.format.ResolverStyle;
|
||||||
@ -126,8 +128,9 @@ public class Tv {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final LocalDateTime topOfHour = LocalDateTime.now().withMinute(0);
|
||||||
final Instant now = Instant.now().truncatedTo(ChronoUnit.MINUTES);
|
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")) {
|
for (final XmlElement prog : tv.getChildren("programme")) {
|
||||||
final String chanId = prog.getAttribute("channel");
|
final String chanId = prog.getAttribute("channel");
|
||||||
final Channel channel = chanIdToChannel.get(chanId);
|
final Channel channel = chanIdToChannel.get(chanId);
|
||||||
|
Loading…
Reference in New Issue
Block a user