From efa5614683ec010bbe70f15a4a4a95983775e99c Mon Sep 17 00:00:00 2001 From: Johnny Tan Date: Wed, 1 May 2024 03:11:15 -0400 Subject: [PATCH] Parse File Date with UTC, Front side restore offset due to Prisma --- src/components/senior/DisplaySenior.tsx | 10 ++++++++-- src/server/model/index.ts | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/senior/DisplaySenior.tsx b/src/components/senior/DisplaySenior.tsx index 6837fb77..3f85149d 100644 --- a/src/components/senior/DisplaySenior.tsx +++ b/src/components/senior/DisplaySenior.tsx @@ -48,6 +48,12 @@ const DisplaySenior = (props: DisplayProps) => { seniorId: senior.id, }); }; + const seniorFiles = senior.Files.map((file) => { + const userTimeZoneOffset = new Date().getTimezoneOffset(); + const newDate = new Date(file.date.getTime() + userTimeZoneOffset * 60000); + const { date, ...other } = file; + return { date: newDate, ...other }; + }); return (
@@ -79,7 +85,7 @@ const DisplaySenior = (props: DisplayProps) => { setFileEdit={canAddFile ? setFileEdit : undefined} /> )} - elements={senior.Files.sort( + elements={seniorFiles.sort( (fileA, fileB) => fileA.date.getTime() - fileB.date.getTime() )} search={(file, filter) => formatFileDate(file.date).includes(filter)} @@ -88,7 +94,7 @@ const DisplaySenior = (props: DisplayProps) => { { const date = new Date(val); - date.setHours(0, 0, 0, 0); - date.toISOString(); + date.setUTCHours(0, 0, 0, 0); return date; }), filetype: z.string(),