fix: use explicit Eastern timezone for day boundary instead of system TZ
Build and Deploy / Build & Push (push) Successful in 2m50s
Build and Deploy / Build & Push (push) Successful in 2m50s
getTodayLocal() relied on system clock hours, which broke in the web container (TZ defaulting to UTC) — the day flipped at 11 PM EDT (3 AM UTC) instead of 3 AM Eastern. Now uses Intl.DateTimeFormat with an explicit America/New_York timezone. Also replaced all toISOString() date formatting with local-component helpers to avoid UTC conversion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type Database from "better-sqlite3";
|
||||
import { getDb } from "./index";
|
||||
import { getTodayLocal } from "../../../lib/env";
|
||||
|
||||
import type { DayData } from "../../../lib/types";
|
||||
export type { DayData };
|
||||
@@ -126,7 +127,7 @@ export function isMonthScraped(
|
||||
): boolean {
|
||||
const daysInMonth = new Date(year, month, 0).getDate();
|
||||
const lastDay = `${year}-${String(month).padStart(2, "0")}-${String(daysInMonth).padStart(2, "0")}`;
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = getTodayLocal();
|
||||
|
||||
if (lastDay < today) return true;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Hono } from "hono";
|
||||
import { PARKS } from "../../../lib/parks";
|
||||
import { QUEUE_TIMES_IDS } from "../../../lib/queue-times-map";
|
||||
import { getCoasterSet } from "../../../lib/coaster-data";
|
||||
import { getTodayLocal, isWithinOperatingWindow, getOperatingStatus } from "../../../lib/env";
|
||||
import { getTodayLocal, formatDateLocal, isWithinOperatingWindow, getOperatingStatus } from "../../../lib/env";
|
||||
import { fetchToday } from "../../../lib/scrapers/sixflags";
|
||||
import { fetchLiveRides } from "../../../lib/scrapers/queuetimes";
|
||||
import { getDateRange, getParkMonthData, type DayData } from "../db/queries";
|
||||
@@ -22,7 +22,7 @@ app.get("/week", async (c) => {
|
||||
const weekDates = Array.from({ length: 7 }, (_, i) => {
|
||||
const d = new Date(startParam + "T00:00:00");
|
||||
d.setDate(d.getDate() + i);
|
||||
return d.toISOString().slice(0, 10);
|
||||
return formatDateLocal(d);
|
||||
});
|
||||
const endDate = weekDates[6];
|
||||
const today = getTodayLocal();
|
||||
@@ -53,7 +53,7 @@ app.get("/week", async (c) => {
|
||||
const currentWeekStart = (() => {
|
||||
const d = new Date(today + "T00:00:00");
|
||||
d.setDate(d.getDate() - d.getDay());
|
||||
return d.toISOString().slice(0, 10);
|
||||
return formatDateLocal(d);
|
||||
})();
|
||||
const isCurrentWeek = startParam === currentWeekStart;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user