fix: properly use date-fns difference functions
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Jul 2023 18:27:08 +0000 (20:27 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Jul 2023 18:27:08 +0000 (20:27 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStationUtils.ts

index 709d1dd11747f4106f5bac1ec9bc0531c6e0fa19..cd586a1cf8329721f72a82d5faef4804583a5a38 100644 (file)
@@ -782,11 +782,11 @@ const getLimitFromChargingProfiles = (
             (index < chargingSchedule.chargingSchedulePeriod.length - 1 &&
               chargingSchedule.duration! >
                 differenceInSeconds(
-                  chargingSchedule.startSchedule!,
                   addSeconds(
                     chargingSchedule.startSchedule!,
                     chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod,
                   ),
+                  chargingSchedule.startSchedule!,
                 ))
           ) {
             const result: ChargingProfilesLimit = {
@@ -829,7 +829,7 @@ const prepareRecurringChargingProfile = (
       ) {
         chargingSchedule.startSchedule = addDays(
           chargingSchedule.startSchedule!,
-          differenceInDays(chargingSchedule.startSchedule!, recurringInterval.end),
+          differenceInDays(recurringInterval.end, chargingSchedule.startSchedule!),
         );
         recurringInterval = {
           start: chargingSchedule.startSchedule,
@@ -849,7 +849,7 @@ const prepareRecurringChargingProfile = (
       ) {
         chargingSchedule.startSchedule = addWeeks(
           chargingSchedule.startSchedule!,
-          differenceInWeeks(chargingSchedule.startSchedule!, recurringInterval.end),
+          differenceInWeeks(recurringInterval.end, chargingSchedule.startSchedule!),
         );
         recurringInterval = {
           start: chargingSchedule.startSchedule,