import moment from "moment";

/** Clock-only values have no browser zone; translated meridiems come from the UI. */
export function clockTimeLabel(value: string | null | undefined, t: (key: string) => string): string {
  if (!value) return "";
  const clock = moment(value, ["HH:mm:ss", "HH:mm"], "en", true);
  return clock.isValid() ? `${clock.format("hh:mm")} ${t(clock.hour() < 12 ? "COMMON.AM" : "COMMON.PM")}` : "";
}

export function clockTimeRange(start: string | null | undefined, end: string | null | undefined, t: (key: string) => string): string {
  return [clockTimeLabel(start, t), clockTimeLabel(end, t)].filter(Boolean).join(" - ");
}
