// src/lib/date-filter.ts
function formatDateUS(raw) {
  if (!raw || raw.trim() === "\u2014" || raw.trim() === "-") return "\u2014";
  if (/^\d{2}\/\d{2}\/\d{4}$/.test(raw.trim())) return raw.trim();
  const d = new Date(raw);
  if (Number.isNaN(d.getTime())) return raw;
  const m = String(d.getMonth() + 1).padStart(2, "0");
  const day = String(d.getDate()).padStart(2, "0");
  const y = d.getFullYear();
  return `${m}/${day}/${y}`;
}
function formatDateFromDate(raw) {
  if (!raw || Number.isNaN(raw.getTime())) return "\u2014";
  const m = String(raw.getMonth() + 1).padStart(2, "0");
  const day = String(raw.getDate()).padStart(2, "0");
  const y = raw.getFullYear();
  return `${m}/${day}/${y}`;
}
function formatDateTimeUS(raw) {
  if (!raw) return "\u2014";
  const d = raw instanceof Date ? raw : new Date(raw);
  if (Number.isNaN(d.getTime())) return String(raw);
  const m = String(d.getMonth() + 1).padStart(2, "0");
  const day = String(d.getDate()).padStart(2, "0");
  const y = d.getFullYear();
  let h = d.getHours();
  const min = String(d.getMinutes()).padStart(2, "0");
  const ampm = h >= 12 ? "PM" : "AM";
  h = h % 12 || 12;
  return `${m}/${day}/${y} ${String(h).padStart(2, "0")}:${min} ${ampm} EST`;
}
function parseRowDateToYmd(raw) {
  const t = raw.trim();
  if (!t || t === "\u2014" || t === "-") return null;
  const d = new Date(t);
  if (Number.isNaN(d.getTime())) return null;
  const y = d.getFullYear();
  const m = String(d.getMonth() + 1).padStart(2, "0");
  const day = String(d.getDate()).padStart(2, "0");
  return `${y}-${m}-${day}`;
}
function formatYmdForDisplay(ymd) {
  const d = ymdToLocalDate(ymd);
  if (!d) return ymd;
  return formatDateFromDate(d);
}
function ymdToLocalDate(ymd) {
  if (!ymd || !/^\d{4}-\d{2}-\d{2}$/.test(ymd)) return void 0;
  const [y, m, d] = ymd.split("-").map(Number);
  return new Date(y, m - 1, d, 12, 0, 0, 0);
}
function localDateToYmd(d) {
  const y = d.getFullYear();
  const m = String(d.getMonth() + 1).padStart(2, "0");
  const day = String(d.getDate()).padStart(2, "0");
  return `${y}-${m}-${day}`;
}
export {
  formatDateFromDate,
  formatDateTimeUS,
  formatDateUS,
  formatYmdForDisplay,
  localDateToYmd,
  parseRowDateToYmd,
  ymdToLocalDate
};
//# sourceMappingURL=date-filter.js.map