From: Jérôme Benoit Date: Mon, 24 Jul 2023 12:22:06 +0000 (+0200) Subject: fix: handle recurring charging profiles only in the past X-Git-Tag: v1.2.20~159^2~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dd41088e0253c8c25ca4ef74a8b96f9e2b968f10;hp=6d52ef25c911dcb8d37ead86819b53a7fe35ef53;p=e-mobility-charging-stations-simulator.git fix: handle recurring charging profiles only in the past Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 090ca65d..8ff88a33 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -8,14 +8,10 @@ import { addDays, addSeconds, addWeeks, - endOfWeek, isAfter, isBefore, - isTomorrow, isYesterday, startOfWeek, - subDays, - subWeeks, } from 'date-fns'; import type { ChargingStation } from './ChargingStation'; @@ -691,21 +687,17 @@ const getLimitFromChargingProfiles = ( ); chargingSchedule.startSchedule = convertToDate(chargingSchedule.startSchedule)!; } - // Adjust recurring schedule + // Adjust recurring start schedule if (chargingProfile.chargingProfileKind === ChargingProfileKindType.RECURRING) { switch (chargingProfile.recurrencyKind) { case RecurrencyKindType.DAILY: if (isYesterday(chargingSchedule.startSchedule)) { addDays(chargingSchedule.startSchedule, 1); - } else if (isTomorrow(chargingSchedule.startSchedule)) { - subDays(chargingSchedule.startSchedule, 1); } break; case RecurrencyKindType.WEEKLY: if (isBefore(chargingSchedule.startSchedule, startOfWeek(currentDate))) { addWeeks(chargingSchedule.startSchedule, 1); - } else if (isAfter(chargingSchedule.startSchedule, endOfWeek(currentDate))) { - subWeeks(chargingSchedule.startSchedule, 1); } break; }