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:
@@ -11,7 +11,7 @@ import FormModal from "../components/FormModal";
|
||||
import FormField from "../components/FormField";
|
||||
import Forbidden from "../components/Forbidden";
|
||||
import { formatDate } from "../utils/attendanceHelpers";
|
||||
import { formatKm } from "../utils/formatters";
|
||||
import { formatKm, todayLocalStr } from "../utils/formatters";
|
||||
import apiFetch from "../utils/api";
|
||||
import {
|
||||
tripListOptions,
|
||||
@@ -53,7 +53,7 @@ export default function Trips() {
|
||||
}>({ show: false, tripId: null });
|
||||
const [form, setForm] = useState<TripForm>({
|
||||
vehicle_id: "",
|
||||
trip_date: new Date().toISOString().split("T")[0],
|
||||
trip_date: todayLocalStr(),
|
||||
start_km: "",
|
||||
end_km: "",
|
||||
route_from: "",
|
||||
@@ -117,10 +117,9 @@ export default function Trips() {
|
||||
|
||||
const openCreateModal = () => {
|
||||
setEditingTrip(null);
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
setForm({
|
||||
vehicle_id: "",
|
||||
trip_date: today,
|
||||
trip_date: todayLocalStr(),
|
||||
start_km: "",
|
||||
end_km: "",
|
||||
route_from: "",
|
||||
|
||||
Reference in New Issue
Block a user