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:
parent
8666ff73c3
commit
c1270f6c9c
1 changed files with 11 additions and 2 deletions
|
|
@ -49,6 +49,9 @@ export default function EventBracket({
|
||||||
const [selectedWinners, setSelectedWinners] = useState<Record<string, string>>({});
|
const [selectedWinners, setSelectedWinners] = useState<Record<string, string>>({});
|
||||||
const [knockoutAssignments, setKnockoutAssignments] = useState<Record<string, string>>({});
|
const [knockoutAssignments, setKnockoutAssignments] = useState<Record<string, string>>({});
|
||||||
const [expandedMatches, setExpandedMatches] = useState<Set<string>>(new Set());
|
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) => {
|
const toggleMatchExpanded = (matchId: string) => {
|
||||||
setExpandedMatches(prev => {
|
setExpandedMatches(prev => {
|
||||||
|
|
@ -723,7 +726,13 @@ export default function EventBracket({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Add game form */}
|
{/* 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="intent" value="add-game" />
|
||||||
<input type="hidden" name="matchId" value={match.id} />
|
<input type="hidden" name="matchId" value={match.id} />
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
|
|
@ -739,7 +748,7 @@ export default function EventBracket({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<Label className="text-xs">Date & Time</Label>
|
<Label className="text-xs">Date & Time ({localTzAbbr})</Label>
|
||||||
<Input
|
<Input
|
||||||
name="scheduledAt"
|
name="scheduledAt"
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue