export const extractDate = (datetime1?: string, timestamp?: Date): string => {
  if (datetime1) {
    // Extract only date part (before " - ")
    return datetime1.split(" - ")[0] || "";
  }
  if (timestamp) {
    // Format timestamp to Persian date only (no time)
    return timestamp.toLocaleDateString("fa-IR");
  }
  return "";
};

export const extractTime = (datetime1?: string, timestamp?: Date): string => {
  if (datetime1) {
    // Extract only time part (after " - ")
    return datetime1.split(" - ")[1] || "";
  }
  if (timestamp) {
    // Format timestamp to time only
    return formatTimestamp(timestamp);
  }
  return "";
};

export const formatTimestamp = (timestamp: Date): string => {
  return timestamp.toLocaleTimeString("fa-IR", {
    hour: "2-digit",
    minute: "2-digit",
  });
};
