"use client"; // A from/to pair of native date inputs. Values are the inputs' own // "YYYY-MM-DD" strings; dayStart/dayEnd turn them into the local-midnight // bounds a started_at range query needs, so "to" includes the whole day. export function dayStart(ymd: string): Date | undefined { if (!ymd) return undefined; const [y, m, d] = ymd.split("-").map(Number); return new Date(y, m - 1, d, 0, 0, 0, 0); } export function dayEnd(ymd: string): Date | undefined { if (!ymd) return undefined; const [y, m, d] = ymd.split("-").map(Number); return new Date(y, m - 1, d, 23, 59, 59, 999); } const inputClass = "bg-surface border border-line rounded-lg px-2 py-1.5 text-sm text-ink-2 focus:outline-none focus:border-accent"; export function DateRange({ from, to, onChange, }: { from: string; to: string; onChange: (from: string, to: string) => void; }) { return (
onChange(e.target.value, to)} className={inputClass} /> to onChange(from, e.target.value)} className={inputClass} /> {(from || to) && ( )}
); }