fix(completion): use local date for the "today" suggestion
Some checks failed
Deploy to GitHub Pages / build (push) Failing after 22s
Deploy to GitHub Pages / deploy (push) Has been skipped

Slicing the UTC ISO string showed the wrong calendar day near
midnight for non-UTC authors. Build it from local getFullYear/
getMonth/getDate so it matches the day the author actually sees.
This commit is contained in:
Julien Calixte
2026-06-19 18:45:58 +02:00
parent e42987a070
commit d26ebeef71

View File

@@ -119,9 +119,12 @@ function result(from: number, to: number, items: Completion[]): CompletionContex
return items.length ? { from, to, items } : null return items.length ? { from, to, items } : null
} }
/** Today as yyyy-mm-dd (UTC, matching `toYmd`). Injectable keeps tests stable. */ /** Today as yyyy-mm-dd in the author's local zone — the calendar day they see,
* not UTC's (which slips a day near midnight). Injectable keeps tests stable. */
function todayYmd(): string { function todayYmd(): string {
return new Date().toISOString().slice(0, 10) const d = new Date()
const pad = (n: number) => String(n).padStart(2, "0")
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
} }
/** Date suggestions: the full date (easy to tweak the day/month in place) and /** Date suggestions: the full date (easy to tweak the day/month in place) and