Derive today via todayKst in kboRepository

- mergeLiveIntoSchedule·fetchScheduleMonth의 formatYmd(new Date())를 todayKst().replace로 교체 — 서버 TZ 의존 제거, 정규 KST 헬퍼로 통일
- 명시적 날짜용 formatYmd와 경기 시간대 시(hour) 게이트는 그대로 유지
- TODO.md 해당 항목 종결
This commit is contained in:
윤정민 2026-06-27 00:20:44 +09:00
parent 6d78ef5c7a
commit 526a8ef731
2 changed files with 6 additions and 5 deletions

View File

@ -25,5 +25,5 @@
- [ ] 라이브 상세 필드 별도 엔드포인트로 노출 - [ ] 라이브 상세 필드 별도 엔드포인트로 노출
- 이닝/카운트/주자/현재 타자·투수는 "스케줄 파악" 목적에서 제외했으나, 라이브 상세 화면 필요 시 `getGameList` 직접 노출하는 별도 핸들러 추가 고려 - 이닝/카운트/주자/현재 타자·투수는 "스케줄 파악" 목적에서 제외했으나, 라이브 상세 화면 필요 시 `getGameList` 직접 노출하는 별도 핸들러 추가 고려
- [ ] `formatYmd(new Date())``todayKst()` 기반으로 통일 - [x] `formatYmd(new Date())``todayKst()` 기반으로 통일
- 현재 TZ=Asia/Seoul 의존. 환경 변경 시 취약 - "오늘" 도출은 TZ 독립 헬퍼(`todayKst`)로 통일 완료. 경기 시간대 시(hour) 게이트는 의도적으로 서버로컬(KST) 유지.

View File

@ -28,6 +28,7 @@ import {
} from "./kboCacheRepository"; } from "./kboCacheRepository";
import { firestore } from "../firebase"; import { firestore } from "../firebase";
import { getGameList } from "../services/gameListService"; import { getGameList } from "../services/gameListService";
import { todayKst } from "../types/dateString";
import type { GameListRecord } from "../kbo/game-list"; import type { GameListRecord } from "../kbo/game-list";
const TTL_MS = 60 * 60 * 1000; // 1 hour const TTL_MS = 60 * 60 * 1000; // 1 hour
@ -224,7 +225,7 @@ const liveGameListCache = new Map<string, { at: number; games: GameListRecord[]
* "예정" "종료" fetch가 . * "예정" "종료" fetch가 .
* (ymd) `ymd !== today` . * (ymd) `ymd !== today` .
*/ */
// 서버 로컬시간 = KST(.env의 TZ=Asia/Seoul). 위의 formatYmd(new Date())와 동일 기준. // 경기 시간대 게이트는 시(hour) 단위라 서버 로컬시간(=KST, .env TZ=Asia/Seoul)으로 충분.
const KST_GAME_WINDOW_START_HOUR = 14; const KST_GAME_WINDOW_START_HOUR = 14;
async function getLiveGameListCached( async function getLiveGameListCached(
@ -249,7 +250,7 @@ async function mergeLiveIntoSchedule(
series: string | undefined series: string | undefined
): Promise<ScheduleGame[]> { ): Promise<ScheduleGame[]> {
// 서버 로컬 타임존 기준 "오늘" 날짜. ymd와 비교해 실시간 병합 여부를 결정한다. // 서버 로컬 타임존 기준 "오늘" 날짜. ymd와 비교해 실시간 병합 여부를 결정한다.
const today = formatYmd(new Date()); const today = todayKst().replace(/-/g, "");
console.log(`[kbo-merge] enter ymd=${ymd} today=${today} games=${games.length}`); console.log(`[kbo-merge] enter ymd=${ymd} today=${today} games=${games.length}`);
// 오늘이 아닌 날짜는 실시간 정보가 의미 없으므로 외부 호출 없이 즉시 반환한다. // 오늘이 아닌 날짜는 실시간 정보가 의미 없으므로 외부 호출 없이 즉시 반환한다.
@ -456,7 +457,7 @@ async function fetchScheduleMonth(
} }
const games: ScheduleGame[] = []; const games: ScheduleGame[] = [];
const today = formatYmd(new Date()); const today = todayKst().replace(/-/g, "");
for (const ymd of allDays) { for (const ymd of allDays) {
const list = cached.get(dayKey(ymd, filters.team, filters.series)) ?? []; const list = cached.get(dayKey(ymd, filters.team, filters.series)) ?? [];
if (ymd === today) { if (ymd === today) {