From dd41088e0253c8c25ca4ef74a8b96f9e2b968f10 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 24 Jul 2023 14:22:06 +0200 Subject: [PATCH] fix: handle recurring charging profiles only in the past MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStationUtils.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) 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; } -- 2.34.1