fix(calendar): use date-only strings for all-day events to prevent timezone shift
UTC midnight passed to FullCalendar's timeZone:'local' was being converted to local time, shifting all-day events back by 1+ days for users in UTC-X zones. The edit form had the same bug via new Date(). Fix: pass YYYY-MM-DD slices (UTC date) for all-day events in both toFcEvent and EventSlideOver resetForm, bypassing timezone conversion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -68,9 +68,11 @@ function resetForm() {
|
|||||||
if (props.event) {
|
if (props.event) {
|
||||||
title.value = props.event.title;
|
title.value = props.event.title;
|
||||||
allDay.value = props.event.all_day;
|
allDay.value = props.event.all_day;
|
||||||
startDate.value = dateFromIso(props.event.start_dt);
|
// All-day events: use UTC date string directly to avoid timezone shifting
|
||||||
|
// (UTC midnight parsed through new Date() becomes the previous day in UTC-X zones)
|
||||||
|
startDate.value = props.event.all_day ? props.event.start_dt.slice(0, 10) : dateFromIso(props.event.start_dt);
|
||||||
startTime.value = props.event.all_day ? "" : timeFromIso(props.event.start_dt);
|
startTime.value = props.event.all_day ? "" : timeFromIso(props.event.start_dt);
|
||||||
endDate.value = props.event.end_dt ? dateFromIso(props.event.end_dt) : "";
|
endDate.value = props.event.end_dt ? (props.event.all_day ? props.event.end_dt.slice(0, 10) : dateFromIso(props.event.end_dt)) : "";
|
||||||
endTime.value = props.event.end_dt && !props.event.all_day ? timeFromIso(props.event.end_dt) : "";
|
endTime.value = props.event.end_dt && !props.event.all_day ? timeFromIso(props.event.end_dt) : "";
|
||||||
description.value = props.event.description || "";
|
description.value = props.event.description || "";
|
||||||
location.value = props.event.location || "";
|
location.value = props.event.location || "";
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ function closeSlideOver() {
|
|||||||
const eventCache = new Map<number, EventEntry>();
|
const eventCache = new Map<number, EventEntry>();
|
||||||
|
|
||||||
function toFcEvent(e: EventEntry) {
|
function toFcEvent(e: EventEntry) {
|
||||||
|
// For all-day events pass date-only strings so FullCalendar never shifts
|
||||||
|
// the date through timezone conversion (UTC midnight → previous day in UTC-X).
|
||||||
return {
|
return {
|
||||||
id: String(e.id),
|
id: String(e.id),
|
||||||
title: e.title,
|
title: e.title,
|
||||||
start: e.start_dt,
|
start: e.all_day ? e.start_dt.slice(0, 10) : e.start_dt,
|
||||||
end: e.end_dt ?? undefined,
|
end: e.all_day ? (e.end_dt?.slice(0, 10) ?? undefined) : (e.end_dt ?? undefined),
|
||||||
allDay: e.all_day,
|
allDay: e.all_day,
|
||||||
backgroundColor: e.color || undefined,
|
backgroundColor: e.color || undefined,
|
||||||
borderColor: e.color || undefined,
|
borderColor: e.color || undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user