diff --git a/app/src/plugins/dates.ts b/app/src/plugins/dates.ts index 539a53e1a..739036161 100644 --- a/app/src/plugins/dates.ts +++ b/app/src/plugins/dates.ts @@ -18,15 +18,20 @@ const DAY_MS = 24 * 60 * 60 * 1000; export function renderDaysAgo(lastUpdated: number) { - const now = new Date().getTime(); + const now = new Date(); - const diff = now - lastUpdated; + const diff = now.getTime() - lastUpdated; const daysAgo = Math.floor(diff / DAY_MS); if (daysAgo <= 0) { return "today"; } else if (daysAgo === 1) { return "yesterday"; + } else if (daysAgo > 30) { + const lastUpdatedDate = new Date(lastUpdated); + let monthsAgo = (now.getFullYear() - lastUpdatedDate.getFullYear()) * 12; + monthsAgo = monthsAgo + now.getMonth() - lastUpdatedDate.getMonth(); + return `${monthsAgo} months ago`; } else { return `${daysAgo} days ago`; }