/**
 * Calculates the difference in weeks between two dates.
 * @param date1 - The first date.
 * @param date2 - The second date.
 */
function dateDiffInWeeks(date1: number, date2: number): number {
	date1 = Number(date1);
	date2 = Number(date2);
	if (date1 <= 0 || date2 <= 0) {
		return 0;
	}
	// Calculate the absolute difference in time (milliseconds)
	const differenceInMilliseconds = Math.abs(date1 - date2);
	// Convert the difference to weeks
	const millisecondsInWeek = 6048e5; // 7 days * 24 hours * 60 minutes * 60 seconds * 1000 milliseconds
	return Math.floor(differenceInMilliseconds / millisecondsInWeek);
}

// Example usage:
// console.log(dateDiffInWeeks(date1, date2)); // Output: 48

export default dateDiffInWeeks;
