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:
@@ -328,7 +328,8 @@ export function EventModal({ type, babyId, onClose, onSaved, initialEvent }: Pro
|
|||||||
let resolvedEndedAt = form.endedAt;
|
let resolvedEndedAt = form.endedAt;
|
||||||
if (config.hasDuration && !resolvedEndedAt && config.defaultDurationMin) {
|
if (config.hasDuration && !resolvedEndedAt && config.defaultDurationMin) {
|
||||||
const start = new Date(form.startedAt);
|
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);
|
localStorage.removeItem(TIMER_KEY);
|
||||||
|
|||||||
Reference in New Issue
Block a user