- (schedulePeriod) =>
- isWithinInterval(
- addSeconds(
- storedChargingProfile.chargingSchedule.startSchedule!,
- schedulePeriod.startPeriod,
- ),
- {
- start: chargingProfilesInterval.end,
- end: interval.end,
- },
- ),
+ (schedulePeriod, index) => {
+ if (
+ isWithinInterval(
+ addSeconds(
+ storedChargingProfile.chargingSchedule.startSchedule!,
+ schedulePeriod.startPeriod,
+ ),
+ {
+ start: chargingProfilesInterval.end,
+ end: interval.end,
+ },
+ )
+ ) {
+ return true;
+ }
+ if (
+ !isWithinInterval(
+ addSeconds(
+ storedChargingProfile.chargingSchedule.startSchedule!,
+ schedulePeriod.startPeriod,
+ ),
+ {
+ start: chargingProfilesInterval.end,
+ end: interval.end,
+ },
+ ) &&
+ index <
+ storedChargingProfile.chargingSchedule.chargingSchedulePeriod.length - 1 &&
+ isWithinInterval(
+ addSeconds(
+ storedChargingProfile.chargingSchedule.startSchedule!,
+ storedChargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1]
+ .startPeriod,
+ ),
+ {
+ start: chargingProfilesInterval.end,
+ end: interval.end,
+ },
+ )
+ ) {
+ return true;
+ }
+ return false;
+ },