fix: use park timezone for operating window check; show tz in hours
All checks were successful
Build and Deploy / Build & Push (push) Successful in 4m22s
All checks were successful
Build and Deploy / Build & Push (push) Successful in 4m22s
- isWithinOperatingWindow now accepts an IANA timezone and reads the current time in the park's local timezone via Intl.DateTimeFormat, fixing false positives when the server runs in UTC but parks store hours in local time (e.g. Pacific parks showing open at 6:50 AM EDT) - Remove the 1-hour pre-open buffer so parks are not marked open before their doors actually open; retain the 1-hour post-close grace period - Add getTimezoneAbbr() helper to derive the short tz label (EDT, PDT…) - All hours labels now display with the local timezone abbreviation (e.g. "10am – 6pm PDT") in WeekCalendar, ParkCard, and ParkMonthCalendar Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Link from "next/link";
|
||||
import type { DayData } from "@/lib/db";
|
||||
import { getTimezoneAbbr } from "@/lib/env";
|
||||
|
||||
interface ParkMonthCalendarProps {
|
||||
parkId: string;
|
||||
@@ -7,6 +8,7 @@ interface ParkMonthCalendarProps {
|
||||
month: number; // 1-indexed
|
||||
monthData: Record<string, DayData>; // 'YYYY-MM-DD' → DayData
|
||||
today: string; // YYYY-MM-DD
|
||||
timezone: string; // IANA timezone, e.g. "America/New_York"
|
||||
}
|
||||
|
||||
const DOW_LABELS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
@@ -29,7 +31,8 @@ function daysInMonth(year: number, month: number): number {
|
||||
return new Date(year, month, 0).getDate();
|
||||
}
|
||||
|
||||
export function ParkMonthCalendar({ parkId, year, month, monthData, today }: ParkMonthCalendarProps) {
|
||||
export function ParkMonthCalendar({ parkId, year, month, monthData, today, timezone }: ParkMonthCalendarProps) {
|
||||
const tzAbbr = getTimezoneAbbr(timezone);
|
||||
const firstDow = new Date(year, month - 1, 1).getDay(); // 0=Sun
|
||||
const totalDays = daysInMonth(year, month);
|
||||
|
||||
@@ -184,7 +187,7 @@ export function ParkMonthCalendar({ parkId, year, month, monthData, today }: Par
|
||||
Passholder
|
||||
</div>
|
||||
<div style={{ fontSize: "0.65rem", color: "var(--color-ph-hours)", marginTop: 2 }}>
|
||||
{dayData.hoursLabel}
|
||||
{dayData.hoursLabel} {tzAbbr}
|
||||
</div>
|
||||
</div>
|
||||
) : isOpen ? (
|
||||
@@ -195,7 +198,7 @@ export function ParkMonthCalendar({ parkId, year, month, monthData, today }: Par
|
||||
padding: "3px 6px",
|
||||
}}>
|
||||
<div style={{ fontSize: "0.65rem", color: "var(--color-open-hours)" }}>
|
||||
{dayData.hoursLabel}
|
||||
{dayData.hoursLabel} {tzAbbr}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user