refactor(v026): #3+#19+#34 KST helper 통합 → src/shared/util/kstDate.ts

기존 src/main/util/kstDate.ts (2 함수) 를 shared 로 이동 + kstTodayAsDate 추가.
main + renderer 양쪽 import 가능. 6 callsite 통합:
- NoteRepository.findExpiredCandidates (todayInKstString → kstTodayIso)
- TelemetryService.todayKstIso (inline 제거)
- telemetryStats.kstDate (inline 제거)
- AiWorker.todayKstAsDate / todayKstAsIso (inline 제거)
- store.snoozeExpired + snoozeRecall (inline 제거 → nextKstMidnightMs)

API: kstTodayIso(now) / nextKstMidnightMs(now) / kstTodayAsDate(now)
+ KST_OFFSET_MS, DAY_MS 상수 export.

단위 +4 cases (boundary, format, midnight, asDate). 418 → 422.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
altair823
2026-05-05 01:27:25 +09:00
parent 075f395b6d
commit 3cfa60bbba
8 changed files with 87 additions and 79 deletions

View File

@@ -1,7 +1,7 @@
import type Database from 'better-sqlite3';
import { v7 as uuidv7, v4 as uuidv4 } from 'uuid';
import type { Note, NoteMedia, NoteTag } from '@shared/types';
import { todayInKstString } from '../util/kstDate.js';
import { kstTodayIso } from '../../shared/util/kstDate.js';
export interface CreateNoteInput { rawText: string; }
@@ -601,7 +601,7 @@ export class NoteRepository {
* Caller may inject `now` for testability; defaults to `new Date()`.
*/
findExpiredCandidates(now: Date = new Date()): Note[] {
const today = todayInKstString(now);
const today = kstTodayIso(now);
const rows = this.db
.prepare(
`SELECT * FROM notes