diff --git a/app/pages/admin/events/create.vue b/app/pages/admin/events/create.vue index 07267e5..7f910fe 100644 --- a/app/pages/admin/events/create.vue +++ b/app/pages/admin/events/create.vue @@ -649,6 +649,16 @@ const eventForm = reactive({ }, }); +// Format a Date/ISO value into a datetime-local string using local-time components. +// `toISOString().slice(0,16)` drifts by the browser's UTC offset on edit round-trip. +const formatForDatetimeLocal = (value) => { + if (!value) return ""; + const d = new Date(value); + if (isNaN(d.getTime())) return ""; + const pad = (n) => String(n).padStart(2, "0"); + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`; +}; + // Agenda management functions const addAgendaItem = () => { eventForm.agenda.push(""); @@ -711,8 +721,8 @@ if (route.query.edit) { description: event.description, content: event.content || "", featureImage: event.featureImage || null, - startDate: new Date(event.startDate).toISOString().slice(0, 16), - endDate: new Date(event.endDate).toISOString().slice(0, 16), + startDate: formatForDatetimeLocal(event.startDate), + endDate: formatForDatetimeLocal(event.endDate), eventType: event.eventType, location: event.location || "", isOnline: event.isOnline, @@ -723,9 +733,7 @@ if (route.query.edit) { tags: event.tags || [], maxAttendees: event.maxAttendees || "", registrationRequired: event.registrationRequired, - registrationDeadline: event.registrationDeadline - ? new Date(event.registrationDeadline).toISOString().slice(0, 16) - : "", + registrationDeadline: formatForDatetimeLocal(event.registrationDeadline), agenda: event.agenda || [], tickets: event.tickets || { enabled: false, @@ -746,13 +754,10 @@ if (route.query.edit) { description: "", }, }); - // Handle early bird deadline formatting if (event.tickets?.public?.earlyBirdDeadline) { - eventForm.tickets.public.earlyBirdDeadline = new Date( + eventForm.tickets.public.earlyBirdDeadline = formatForDatetimeLocal( event.tickets.public.earlyBirdDeadline, - ) - .toISOString() - .slice(0, 16); + ); } } } catch (error) {