brackt/app/hooks/useLocalTimezone.ts
Claude 1831898001
Address code review: shared tz hook, short abbrev, sort fix, dead type cleanup, test update
- Extract timezone detection into useLocalTimezone hook to avoid duplication
  across DraftSetupSection and Step3DraftSettings
- Use Intl short timezone abbreviation (e.g. "EST") instead of raw IANA name,
  matching DraftInfoCard's existing pattern
- Sort review step sport list by season name instead of sport.name so the
  visible order matches the displayed text
- Remove unused scoringType and year fields from SportsSection's local type
- Update SportsSection tests to use realistic season names and the new
  display format

https://claude.ai/code/session_01GtJowGruAc1A4jURkSDVjX
2026-05-15 22:25:28 +00:00

10 lines
337 B
TypeScript

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;
}