9 lines
486 B
JavaScript
9 lines
486 B
JavaScript
// Returns the day key of `date` in local time, for example "2026-09-21".
|
|
// toISOString() is deliberately avoided: it converts to UTC and would move the key
|
|
// to the previous or next day depending on the time of day and the time zone.
|
|
export function formatDateKey(date) {
|
|
const year = String(date.getFullYear()).padStart(4, '0')
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
return `${year}-${month}-${day}`
|
|
}
|