import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import { DateType } from "react-native-ui-datepicker";

dayjs.extend(utc);
dayjs.extend(timezone);

export function formatDateOnly(
  date?: DateType,
  format: "DD-MM-YYYY" | "YYYY-MM-DD" = "DD-MM-YYYY"
) {
  if (!date) return "";

  return dayjs(date)
    .tz(dayjs.tz.guess())
    .format(format);
}
