};
}),
...compositeChargingScheduleLower!.chargingSchedulePeriod
- .filter((schedulePeriod) => {
+ .filter((schedulePeriod, index) => {
if (
higherFirst &&
isWithinInterval(
) {
return false;
}
+ if (
+ higherFirst &&
+ index < compositeChargingScheduleLower!.chargingSchedulePeriod.length - 1 &&
+ !isWithinInterval(
+ addSeconds(
+ compositeChargingScheduleLowerInterval.start,
+ schedulePeriod.startPeriod,
+ ),
+ {
+ start: compositeChargingScheduleLowerInterval.start,
+ end: compositeChargingScheduleHigherInterval.end,
+ },
+ ) &&
+ isWithinInterval(
+ addSeconds(
+ compositeChargingScheduleLowerInterval.start,
+ compositeChargingScheduleLower!.chargingSchedulePeriod[index + 1].startPeriod,
+ ),
+ {
+ start: compositeChargingScheduleLowerInterval.start,
+ end: compositeChargingScheduleHigherInterval.end,
+ },
+ )
+ ) {
+ schedulePeriod.startPeriod = 0;
+ return false;
+ }
if (
!higherFirst &&
isWithinInterval(