// src/utils/timeAgo.ts

export function timeAgo(dateString: string) {
  const rtf = new Intl.RelativeTimeFormat("tr", { numeric: "auto" })
  const diffMs = new Date(dateString).getTime() - Date.now()
  const diffSec = Math.floor(diffMs / 1000)

  const absSec = Math.abs(diffSec)
  if (absSec < 60) return rtf.format(Math.round(diffSec / 1), "second")
  if (absSec < 3600) return rtf.format(Math.round(diffSec / 60), "minute")
  if (absSec < 86400) return rtf.format(Math.round(diffSec / 3600), "hour")
  return rtf.format(Math.round(diffSec / 86400), "day")
}
