},
)
) {
- schedulePeriod.startPeriod = 0;
return false;
}
if (
}
return true;
})
- .map((schedulePeriod) => {
+ .map((schedulePeriod, index) => {
+ if (index === 0 && schedulePeriod.startPeriod !== 0) {
+ schedulePeriod.startPeriod = 0;
+ }
return {
...schedulePeriod,
startPeriod: higherFirst
...chargingSchedule,
startSchedule: targetInterval.start as Date,
duration: differenceInSeconds(chargingScheduleInterval.end, targetInterval.start as Date),
- chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(
- (schedulePeriod, index) => {
+ chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod
+ .filter((schedulePeriod, index) => {
if (
isWithinInterval(
addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
targetInterval,
)
) {
- schedulePeriod.startPeriod = 0;
return true;
}
return false;
- },
- ),
+ })
+ .map((schedulePeriod, index) => {
+ if (index === 0 && schedulePeriod.startPeriod !== 0) {
+ schedulePeriod.startPeriod = 0;
+ }
+ return schedulePeriod;
+ }),
};
}
if (isAfter(chargingScheduleInterval.end, targetInterval.end)) {