M9 S3 (frontend): consolidate local-date helpers into notes/datetime.ts
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 6s
CI & Build / Python tests (push) Successful in 11s
CI & Build / Build & push image (push) Successful in 30s

The created-date range facets built local-day bounds by hand in two places
(FilterBar's onTo/toInput, TimelineView's buildQuery) — parse a
"YYYY-MM-DD", shift a day for the half-open upper bound, format back.

- datetime.ts: parseLocalDate() / addLocalDays() (non-mutating) / formatLocalDay().
- TimelineView: drops its inline localDate() + the +1-day Date math.
- FilterBar: drops its inline isoDay() + the setDate(±1) mutations.

Behavior-preserving and deliberately NOT unifying output: Timeline still
emits UTC (.toISOString()) bounds, FilterBar still emits naive-local
"…T00:00:00" strings — only the shared primitives are extracted. (The
naive-vs-UTC divergence is a separate backend-datetime-semantics question,
flagged for later, not silently changed.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
2026-07-23 21:40:13 -04:00
co-authored by Claude Opus 4.8
parent 590d3ff2f6
commit e1cf63e875
3 changed files with 35 additions and 25 deletions
+23
View File
@@ -26,3 +26,26 @@ export function formatReminder(iso: string | null): string {
export function isOverdue(iso: string | null): boolean {
return !!iso && new Date(iso).getTime() < Date.now();
}
// --- Local calendar-date helpers (the created-date range facets work in the viewer's
// LOCAL day; the board's FilterBar and the Timeline view both build day bounds). ---
// Parse an <input type="date"> value ("YYYY-MM-DD") as a LOCAL calendar date (midnight
// local), or null if it isn't a valid YYYY-MM-DD.
export function parseLocalDate(value: string): Date | null {
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
if (!m) return null;
return new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));
}
// A new local Date shifted by whole days — e.g. +1 for the half-open upper bound that
// includes the whole end day, -1 to reverse it for display. Non-mutating.
export function addLocalDays(d: Date, days: number): Date {
return new Date(d.getFullYear(), d.getMonth(), d.getDate() + days);
}
// Format a local Date as "YYYY-MM-DD" (the shape an <input type="date"> reads).
export function formatLocalDay(d: Date): string {
const pad = (n: number) => String(n).padStart(2, "0");
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}