import { useState, useEffect } from "react";

export function useLocalTimezone() {
  const [tz, setTz] = useState("");
  useEffect(() => {
    const parts = Intl.DateTimeFormat(undefined, { timeZoneName: "short" }).formatToParts(new Date());
    setTz(parts.find((p) => p.type === "timeZoneName")?.value ?? "");
  }, []);
  return tz;
}
