diff --git a/src/app/api/file/[fileId]/route.ts b/src/app/api/file/[fileId]/route.ts index 4abdbc54..bc59d195 100644 --- a/src/app/api/file/[fileId]/route.ts +++ b/src/app/api/file/[fileId]/route.ts @@ -58,9 +58,8 @@ export const PATCH = withSession(async ({ params, session, req }) => { { status: 400 } ); } - const userTimeZoneOffset = new Date().getTimezoneOffset(); const newDate = new Date( - fileData.date.getTime() + userTimeZoneOffset * 60000 + fileData.date.getTime() + new Date().getTimezoneOffset() * 60000 ); const formatted_date = moment(newDate).format("L"); diff --git a/src/app/api/file/route.ts b/src/app/api/file/route.ts index ce055aac..b3808b74 100644 --- a/src/app/api/file/route.ts +++ b/src/app/api/file/route.ts @@ -65,9 +65,8 @@ export const POST = withSession(async (request) => { const parentID = foundSenior.folder; - const userTimeZoneOffset = new Date().getTimezoneOffset(); const newDate = new Date( - fileData.date.getTime() + userTimeZoneOffset * 60000 + fileData.date.getTime() + new Date().getTimezoneOffset() * 60000 ); const formatted_date = moment(newDate).format("L"); diff --git a/src/components/senior/DisplaySenior.tsx b/src/components/senior/DisplaySenior.tsx index 3f85149d..ebedb595 100644 --- a/src/components/senior/DisplaySenior.tsx +++ b/src/components/senior/DisplaySenior.tsx @@ -48,13 +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 }; - }); - + const seniorFiles = senior.Files.map((file) => ({ + ...file, + date: new Date( + file.date.getTime() + new Date().getTimezoneOffset() * 60000 + ), + })); return (