"use client";

import { useCallback } from "react";

import { formatAdminInstant } from "@/lib/admin-datetime";
import { getAdminRequestLocale } from "@/lib/admin-locale";

/**
 * 按当前界面语言 + **浏览器本地时区** 格式化时间。
 */
export function useAdminDateTimeFormatter(): (
  iso: string | null | undefined,
) => string {
  return useCallback(
    (iso) =>
      formatAdminInstant(iso, {
        locale: getAdminRequestLocale(),
      }),
    [],
  );
}
