From b5132581c0f74dcf67b892a187e4db2fee5ab182 Mon Sep 17 00:00:00 2001 From: Vishnu Date: Mon, 19 May 2025 08:24:37 +0530 Subject: [PATCH] date issue 6 --- apps/Frontend/src/pages/appointments-page.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/Frontend/src/pages/appointments-page.tsx b/apps/Frontend/src/pages/appointments-page.tsx index 7e435c8..486371b 100644 --- a/apps/Frontend/src/pages/appointments-page.tsx +++ b/apps/Frontend/src/pages/appointments-page.tsx @@ -372,19 +372,21 @@ export default function AppointmentsPage() { appointmentData: InsertAppointment | UpdateAppointment ) => { // Converts local date to exact UTC date with no offset issues - function getUTCDateOnly(date: Date) { - return new Date( - Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) + + function toUTCDateString(date: Date): string { + return format( + new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())), + "yyyy-MM-dd" ); } const rawDate = appointmentData.date instanceof Date ? appointmentData.date - : new Date(appointmentData.date); + : new Date(appointmentData.date); // this is unsafe if it's "yyyy-MM-dd" const updatedData = { ...appointmentData, - date: getUTCDateOnly(rawDate), // 👈 This ensures consistent date across all environments + date: toUTCDateString(rawDate), // 👈 This ensures consistent date across all environments }; // Check if we're editing an existing appointment with a valid ID