From f9d77f3bdead09d45a772b389ccdbda92b550b42 Mon Sep 17 00:00:00 2001 From: HemalDesai Date: Fri, 13 Sep 2024 11:55:31 +0530 Subject: [PATCH] feat: update createdAt and updatedAt fields to store timestamps in UTC --- app/utils/general.ts | 10 +++++----- server/db/schema.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/utils/general.ts b/app/utils/general.ts index 5aff3302..48d7dcb0 100644 --- a/app/utils/general.ts +++ b/app/utils/general.ts @@ -32,23 +32,23 @@ export function timeAgo(date: Date) { const seconds = Math.floor((now.getTime() - date.getTime()) / 1000); let interval = Math.floor(seconds / 31536000); - if (interval > 1) { + if (interval >= 1) { return `${interval}y ago`; } interval = Math.floor(seconds / 2592000); - if (interval > 1) { + if (interval >= 1) { return `${interval}mo ago`; } interval = Math.floor(seconds / 86400); - if (interval > 1) { + if (interval >= 1) { return `${interval}d ago`; } interval = Math.floor(seconds / 3600); - if (interval > 1) { + if (interval >= 1) { return `${interval}h ago`; } interval = Math.floor(seconds / 60); - if (interval > 1) { + if (interval >= 1) { return `${interval}m ago`; } return `Just Now`; diff --git a/server/db/schema.ts b/server/db/schema.ts index 21423505..2e621726 100644 --- a/server/db/schema.ts +++ b/server/db/schema.ts @@ -48,8 +48,8 @@ export const jobPostingsTable = pgTable('job_postings', { }), isPublished: boolean('is_published').default(false).notNull(), totalApplicants: integer('total_applicants').default(0).notNull(), - createdAt: timestamp('created_at').defaultNow().notNull(), - updatedAt: timestamp('updated_at').defaultNow().notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), }); export type JobPosting = typeof jobPostingsTable.$inferSelect;