/**
 * Shared date/time formatting — one rule per display shape. Views import
 * these instead of carrying a local formatDate(): the 2026-08 shape audit
 * found eight copies across views/components, three of them byte-identical.
 * (The previous Calendar/Home helpers in this file had no callers left and
 * were removed in the same pass.)
 *
 * Relative forms ("5m ago") live next door in composables/useRelativeTime.
 */

/** "Jan 15, 2026" — a date with no time of day (user created_at, key expiry). */
export function fmtDate(iso: string): string {
  return new Date(iso).toLocaleDateString(undefined, {
    year: "numeric", month: "short", day: "numeric",
  });
}

/** "Jan 15, 2026, 09:30 AM" — a full timestamp (task logs, version history). */
export function fmtStamp(iso: string): string {
  return new Date(iso).toLocaleString(undefined, {
    month: "short", day: "numeric", year: "numeric",
    hour: "2-digit", minute: "2-digit",
  });
}

/** "Jan 15, 09:30:05 AM" — log-table timestamp: seconds matter, the year doesn't. */
export function fmtLogStamp(iso: string): string {
  return new Date(iso).toLocaleString(undefined, {
    month: "short", day: "numeric",
    hour: "2-digit", minute: "2-digit", second: "2-digit",
  });
}
