export const DateUtils = {
  short(date?: string | null) {
    if (!date) return "";

    const [y, m, d] =
      date.split("-");

    return `${d}/${m}/${y}`;
  },
  long(date?: string | null) {
    if (!date) return "";
    const d = new Date(date);
    return d.toLocaleDateString("fr-FR",
      {
        weekday: "long",
        day: "2-digit",
        month: "long",
        year: "numeric"
      }
    )
  },
  datetime(date?: string | null) {
    if (!date) return "";

    const d = new Date(date);

    return (
      d.toLocaleDateString("fr-FR")
      + " "
      + d.toLocaleTimeString(
        "fr-FR",
        {
          hour: "2-digit",
          minute: "2-digit"
        }
      ).replace(":", "h")
    );
  },
  audit(date?: string | null) {
    if (!date) return "";

    const d = new Date(date);

    const datePart = d.toLocaleDateString(
      "fr-FR",
      {
        weekday: "long",
        day: "numeric",
        month: "long",
        year: "numeric"
      }
    );

    const hours = String(d.getHours()).padStart(2, "0");

    const minutes = String(d.getMinutes()).padStart(2, "0");

    const seconds = String(d.getSeconds()).padStart(2, "0");

    return `${datePart} ${hours}h${minutes}:${seconds}`;
  }
};