import { format, parseISO } from 'date-fns'

/**
 * Format a date for display in short format (e.g., "Mon, Dec 2")
 */
export function formatDateShort(date: Date | string): string {
  const d = typeof date === 'string' ? parseISO(date) : date
  return format(d, 'EEE, MMM d')
}

/**
 * Format a date for display in long format (e.g., "Monday, December 2, 2024")
 */
export function formatDateLong(date: Date | string): string {
  const d = typeof date === 'string' ? parseISO(date) : date
  return format(d, 'EEEE, MMMM d, yyyy')
}

/**
 * Format a date to ISO date string (YYYY-MM-DD)
 */
export function formatDateISO(date: Date | string): string {
  const d = typeof date === 'string' ? parseISO(date) : date
  return format(d, 'yyyy-MM-dd')
}

/**
 * Get today's date as ISO string (YYYY-MM-DD)
 */
export function getTodayISO(): string {
  return format(new Date(), 'yyyy-MM-dd')
}

/**
 * Format a date with time for display (e.g., "Dec 2, 2024 at 3:45 PM")
 */
export function formatDateTime(date: Date | string): string {
  const d = typeof date === 'string' ? parseISO(date) : date
  return format(d, "MMM d, yyyy 'at' h:mm a")
}
