import { useCallback } from "react";
import { useTimeZone } from "@/app/timezone/TimeZoneProvider.jsx";

export function useAdminTime() {
  const { formatMillis, timeZone, timeZoneLabel } = useTimeZone();

  const formatDateTime = useCallback((value) => formatMillis(value), [formatMillis]);
  const formatRange = useCallback(
    (startValue, endValue, separator = " - ") => {
      const startText = formatMillis(startValue);
      const endText = formatMillis(endValue);
      return startText === "-" && endText === "-" ? "-" : `${startText}${separator}${endText}`;
    },
    [formatMillis]
  );

  return {
    formatDateTime,
    formatRange,
    timeZone,
    timeZoneLabel
  };
}
