diff --git a/utils/PlanningEventManager.js b/utils/PlanningEventManager.js index fad13d9..b703180 100644 --- a/utils/PlanningEventManager.js +++ b/utils/PlanningEventManager.js @@ -13,31 +13,7 @@ export default class PlanningEventManager { return PlanningEventManager.dateToString(new Date()); } - /** - * Gets how many days the event lasts. If no end date is specified, defaults to 1. - * - * - * @param start The start date string in format YYYY-MM-DD HH:MM:SS - * @param end The end date string in format YYYY-MM-DD HH:MM:SS - * @return {number} The number of days, 0 on error - */ - static getEventDaysNumber(start: string, end: string): number { - let startDate = PlanningEventManager.stringToDate(start); - let endDate = PlanningEventManager.stringToDate(end); - if (startDate !== undefined && endDate !== undefined) { - if (startDate.getTime() !== endDate.getTime()) { - const diffTime = endDate - startDate; - return Math.ceil(diffTime / (1000 * 60 * 60 * 24)); - } else - return 1; - } else if (startDate !== undefined) - return 1; - else - return 0; - } - - - /** + /** * Checks if the given date is before the other. * * @param event1Date Event 1 date in format YYYY-MM-DD HH:MM:SS diff --git a/utils/__test__/PlanningEventManager.test.js b/utils/__test__/PlanningEventManager.test.js index 249e2b9..67e0424 100644 --- a/utils/__test__/PlanningEventManager.test.js +++ b/utils/__test__/PlanningEventManager.test.js @@ -127,11 +127,3 @@ test('dateToString', () => { expect(PlanningEventManager.dateToString(testDate)).toBe("2022-12-31 09:10:15"); }); -test('getEventDaysNumber', () => { - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:00:00', '2020-03-22 17:00:00')).toBe(2); - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:00:00', '2020-03-21 17:00:00')).toBe(1); - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:00:00', '2020-03-21 09:00:00')).toBe(1); - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:gg:00', '2020-03-21 17:00:00')).toBe(0); - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:00:00', undefined)).toBe(1); - expect(PlanningEventManager.getEventDaysNumber('2020-03-21 09:00:00', '2020-04-05 20:00:00')).toBe(16); -});