diff --git a/frontend/functions/date.ts b/frontend/functions/date.ts index 38b620e0..76dfdcb1 100644 --- a/frontend/functions/date.ts +++ b/frontend/functions/date.ts @@ -19,27 +19,26 @@ export const formatElapsedDate = (date: Date, timezone: string) => { const seconds = Math.floor(elapsed / 1000) const minutes = Math.floor(seconds / 60) - const hours = Math.floor(minutes / 60) - const days = Math.floor(hours / 24) - const weeks = Math.floor(days / 7) - const months = Math.floor(days / 30) - const years = Math.floor(days / 365) - if (minutes < 1) { return "Now" } + const hours = Math.floor(minutes / 60) if (hours < 1) { return `${minutes} ${minutes === 1 ? "min" : "mins"} ago` } + const days = Math.floor(hours / 24) if (days < 1) { return `${hours} ${hours === 1 ? "hour" : "hours"} ago` } + const weeks = Math.floor(days / 7) if (weeks < 1) { return `${days} ${days === 1 ? "day" : "days"} ago` } + const months = Math.floor(days / 30) if (months < 1) { return `${weeks} ${weeks === 1 ? "week" : "weeks"} ago` } + const years = Math.floor(days / 365) if (years < 1) { return `${months} ${months === 1 ? "month" : "months"} ago` }