fix(completion): use local date for the "today" suggestion
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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user