export const useFormatDateForMessage = (date = '2009-09-01') => {
  const dateObj: any = new Date(date);
  const now: any = new Date();

  const diffInSeconds = Math.floor((now - dateObj) / 1000);

  // Define thresholds
  const timeThresholds = {
    year: 60 * 60 * 24 * 365,
    month: 60 * 60 * 24 * 30,
    week: 60 * 60 * 24 * 7,
    day: 60 * 60 * 24,
    hour: 60 * 60,
    minute: 60,
    second: 1,
  };

  for (const [unit, seconds] of Object.entries(timeThresholds)) {
    if (diffInSeconds >= seconds) {
      const value = Math.floor(diffInSeconds / seconds);
      return `${value} ${unit}${value > 1 ? 's' : ''} ago`;
    }
  }

  return 'just now'; // If the time difference is too small
};
