Fix game datetime timezone handling in bracket admin (#137)

- Convert datetime-local input value to UTC ISO string on form submit
  so server correctly parses local time instead of treating it as UTC
- Show local timezone abbreviation (e.g. PDT) in the field label
- Hoist timezone abbreviation computation out of the matches render loop

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-03-11 15:13:50 -07:00 committed by GitHub
parent 8666ff73c3
commit c1270f6c9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,6 +49,9 @@ export default function EventBracket({
const [selectedWinners, setSelectedWinners] = useState<Record<string, string>>({});
const [knockoutAssignments, setKnockoutAssignments] = useState<Record<string, string>>({});
const [expandedMatches, setExpandedMatches] = useState<Set<string>>(new Set());
const localTzAbbr = new Intl.DateTimeFormat("en-US", { timeZoneName: "short" })
.formatToParts(new Date())
.find(p => p.type === "timeZoneName")?.value ?? "local";
const toggleMatchExpanded = (matchId: string) => {
setExpandedMatches(prev => {
@ -723,7 +726,13 @@ export default function EventBracket({
)}
{/* Add game form */}
<Form method="post" className="flex gap-2 items-end">
<Form method="post" className="flex gap-2 items-end" onSubmit={(e) => {
const form = e.currentTarget;
const scheduledAtInput = form.elements.namedItem("scheduledAt") as HTMLInputElement;
if (scheduledAtInput?.value) {
scheduledAtInput.value = new Date(scheduledAtInput.value).toISOString();
}
}}>
<input type="hidden" name="intent" value="add-game" />
<input type="hidden" name="matchId" value={match.id} />
<div className="flex-1">
@ -739,7 +748,7 @@ export default function EventBracket({
/>
</div>
<div className="flex-1">
<Label className="text-xs">Date &amp; Time</Label>
<Label className="text-xs">Date &amp; Time ({localTzAbbr})</Label>
<Input
name="scheduledAt"
type="datetime-local"