make it work for production too

This commit is contained in:
Julien Calixte
2023-04-11 23:21:49 +02:00
parent 98c5fa5965
commit 71fc42fe1f

View File

@@ -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))))
}