fix(dates): use local 'today' for date-input defaults instead of the UTC date

11 form defaults across 6 files used new Date().toISOString().split('T')[0] (the UTC date), which lands on yesterday during the post-midnight Prague window (UTC+1/+2). Added todayLocalStr() (local YYYY-MM-DD) in formatters and replaced them. Future-date expressions (e.g. invoice due_date +14d) left untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-06 02:38:58 +02:00
parent 94a9fb8b5a
commit 1f05ef6a55
7 changed files with 30 additions and 17 deletions

View File

@@ -23,6 +23,19 @@ export function formatDate(dateStr: string | null | undefined): string {
return d.toLocaleDateString("cs-CZ");
}
/**
* Today's date as `YYYY-MM-DD` in LOCAL (Prague) time — use this for
* date-input defaults. `new Date().toISOString().slice(0, 10)` gives the UTC
* date, which is a day behind the Czech date during the post-midnight window
* (Prague is UTC+1/+2), so a "today" default could land on yesterday.
*/
export function todayLocalStr(): string {
const d = new Date();
const m = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return `${d.getFullYear()}-${m}-${day}`;
}
export function formatKm(km: number | string): string {
return new Intl.NumberFormat("cs-CZ").format(Number(km) || 0);
}