Skip to content

Commit

Permalink
address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny-t06 committed May 1, 2024
1 parent f3ed216 commit 15730bb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/app/api/file/[fileId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
3 changes: 1 addition & 2 deletions src/app/api/file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
13 changes: 6 additions & 7 deletions src/components/senior/DisplaySenior.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex flex-col gap-y-6">
<h1 className="text-4xl font-bold text-[#000022]">
Expand Down
3 changes: 3 additions & 0 deletions src/server/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const seniorSchema = z.object({
ChapterID: z.string(),
}) satisfies z.ZodType<Senior>;

/* https://stackoverflow.com/questions/49407453/setting-sethours-zero-not-working-in-nodejs
Stores Date object at 0:00:00 UTC time
*/
export const File = z.object({
date: z.string().transform((val) => {
const date = new Date(val);
Expand Down

0 comments on commit 15730bb

Please sign in to comment.