From 71fc42fe1ff93d41e7d8790e016b5f057b51ea42 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Tue, 11 Apr 2023 23:21:49 +0200 Subject: [PATCH] make it work for production too --- src/shared/format-date.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/format-date.ts b/src/shared/format-date.ts index 47f8353..4ad6eec 100644 --- a/src/shared/format-date.ts +++ b/src/shared/format-date.ts @@ -1,5 +1,7 @@ import type { ISODate } from './types/date' +const isDevelopment = () => process.env.NODE_ENV === 'development' + export const formatDate = (date: Date | string) => new Date(date).toLocaleString() @@ -15,6 +17,5 @@ export const formatLongDate = (date: Date | ISODate) => export const formatDiffInMinutes = (date1: ISODate, date2: ISODate) => { const diffInMs = new Date(date2).getTime() - new Date(date1).getTime() - // TODO: diff in minutes not in seconds - return Math.max(0, Math.round(diffInMs / 1000)) + return Math.max(0, Math.round(diffInMs / (1000 * (isDevelopment() ? 1 : 60)))) }