forked from vergnet/application-amicale
Removed unused function
This commit is contained in:
parent
40d7985bbd
commit
3824683385
2 changed files with 1 additions and 33 deletions
|
@ -13,31 +13,7 @@ export default class PlanningEventManager {
|
||||||
return PlanningEventManager.dateToString(new Date());
|
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.
|
* Checks if the given date is before the other.
|
||||||
*
|
*
|
||||||
* @param event1Date Event 1 date in format YYYY-MM-DD HH:MM:SS
|
* @param event1Date Event 1 date in format YYYY-MM-DD HH:MM:SS
|
||||||
|
|
|
@ -127,11 +127,3 @@ test('dateToString', () => {
|
||||||
expect(PlanningEventManager.dateToString(testDate)).toBe("2022-12-31 09:10:15");
|
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);
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in a new issue