function isDateOlderThanMaxAge(
  dateString?: string | Date,
  maxAgeDays = 0,
): boolean {
  if (dateString === undefined) {
    return true;
  }
  const date = new Date(dateString);
  const maxAgeMilliseconds = maxAgeDays * 24 * 60 * 60 * 1000;
  const currentDate = new Date();
  const difference = currentDate.getTime() - date.getTime();

  return difference > maxAgeMilliseconds;
}

export default isDateOlderThanMaxAge;
