fix(events): correct timezone double-offset in default duration calc

When endedAt is omitted, the computed end time was stored as a UTC
string then passed through toUTC() which re-parsed it as local time,
applying the timezone offset twice. Express resolvedEndedAt as a local
datetime string to match other form fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 23:22:06 +02:00
parent 41170d9155
commit a844af9c68
+2 -1
View File
@@ -328,7 +328,8 @@ export function EventModal({ type, babyId, onClose, onSaved, initialEvent }: Pro
let resolvedEndedAt = form.endedAt;
if (config.hasDuration && !resolvedEndedAt && config.defaultDurationMin) {
const start = new Date(form.startedAt);
resolvedEndedAt = new Date(start.getTime() + config.defaultDurationMin * 60000).toISOString().slice(0, 16);
const end = new Date(start.getTime() + config.defaultDurationMin * 60000);
resolvedEndedAt = new Date(end.getTime() - end.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
}
localStorage.removeItem(TIMER_KEY);