/**
 * Calculates the difference in days between two dates.
 * @param date1
 * @param date2
 */
const dateDiffInDays = (date1: number, date2: number): number => {
	date1 = Number(date1);
	date2 = Number(date2);
	if (date1 <= 0 || date2 <= 0) {
		return 0;
	}
	// Calculate the absolute difference and convert to days
	const msPerDay = 864e5; // 86400000 milliseconds in a day
	const differenceInMs = Math.abs(date1 - date2);
	return Math.floor(differenceInMs / msPerDay);
};

// const daysDiff = dateDiffInDays(date1, date2);
// console.log(`Difference in days: ${daysDiff}`);
// Output: Difference in days: 24

export default dateDiffInDays;
